Home

Why Does JSX Look Like XML? The Deep Dive into JSX Syntax Design

Published in react
June 04, 2025
2 min read
Why Does JSX Look Like XML? The Deep Dive into JSX Syntax Design

Hey fellow React enthusiasts! 🐻 CodingBear here with another deep dive into React’s core concepts. Today, we’re tackling a fundamental question that puzzles many newcomers: Why does JSX look so much like XML/HTML tags when it’s actually JavaScript? As a React developer with over 20 years of experience (yes, I started before React existed!), I’ll unpack the historical context, technical rationale, and practical benefits behind this design choice. Grab your favorite coffee, and let’s get started!

The Historical Context of JSX

When React was first introduced by Facebook in 2013, the team faced a critical UI development challenge: how to make component rendering both intuitive and efficient. The solution emerged from several key insights:

  1. Developer Familiarity: Most frontend developers were already proficient with HTML-like syntax. By adopting XML-like tags, React lowered the learning curve dramatically.
  2. Visual Clarity: JSX’s tag-based syntax makes component hierarchies visually apparent. Compare these two equivalent representations:
// JSX version
<Card>
<Header title="Welcome" />
<Body content="Hello world!" />
</Card>
// Pure JavaScript version
React.createElement(
Card,
null,
React.createElement(Header, { title: "Welcome" }),
React.createElement(Body, { content: "Hello world!" })
)
  1. Tooling Support: XML-like syntax enabled better editor support (syntax highlighting, autocomplete) right from the early days.

Why Does JSX Look Like XML? The Deep Dive into JSX Syntax Design
Why Does JSX Look Like XML? The Deep Dive into JSX Syntax Design


šŸŽ® If you’re curious about various subjects and technologies, Mastering Java For Loops A Comprehensive Guide for Developersfor more information.

Technical Implementation: JSX Under the Hood

JSX isn’t HTML - it’s syntactic sugar for React.createElement() calls. Here’s what happens during compilation:

  1. Babel Transformation: Your JSX gets converted to JavaScript function calls:
// Before transpilation
const element = <h1 className="title">Hello</h1>;
// After transpilation
const element = React.createElement(
'h1',
{ className: 'title' },
'Hello'
);
  1. Virtual DOM Creation: These function calls create lightweight JavaScript objects (Virtual DOM nodes) that React uses for efficient updates.
  2. Performance Optimization: The explicit tree structure allows React’s reconciliation algorithm to optimize updates with minimal DOM operations.

Why Does JSX Look Like XML? The Deep Dive into JSX Syntax Design
Why Does JSX Look Like XML? The Deep Dive into JSX Syntax Design


šŸ„‚ Whether it’s date night or brunch with friends, don’t miss this review of Humboldt Haus Sandwich Bar to see what makes this place worth a visit.

Why Not Template Literals or Other Alternatives?

The React team considered several alternatives before settling on JSX:

  1. Template Literals: While possible, they become unwieldy for complex components and lack hierarchy visualization.
  2. Hyperscript Syntax: Too verbose for daily use and less readable.
  3. Custom DSLs: Would require developers to learn entirely new syntax rules. JSX struck the perfect balance by:
  • Maintaining JavaScript’s full power (you can embed expressions with {})
  • Providing visual structure matching the UI hierarchy
  • Enabling compile-time optimizations
  • Supporting TypeScript and Flow type checking

Why Does JSX Look Like XML? The Deep Dive into JSX Syntax Design
Why Does JSX Look Like XML? The Deep Dive into JSX Syntax Design


For timing tasks, breaks, or productivity sprints, a browser-based stopwatch tool can be surprisingly effective.

And there you have it! JSX’s XML-like appearance isn’t an accident - it’s a carefully designed syntax that combines the best of markup readability with JavaScript’s flexibility. As we’ve seen, this design choice has stood the test of time, enabling React’s component model while remaining approachable to new developers.
Got more JSX questions? Drop them in the comments below! Until next time, happy coding! šŸ»šŸ’»
CodingBear is a senior React developer and blogger with 20+ years of experience. Follow for more deep dives into React’s internals!

When designing a brand palette, you can use a color picker that instantly shows RGB and HEX codes to streamline your workflow.









Take your first step into the world of Bitcoin! Sign up now and save on trading fees! bitget.com Quick link
Take your first step into the world of Bitcoin! Sign up now and save on trading fees! bitget.com Quick link




Tags

#developer#coding#react

Share

Previous Article
Mastering Python KeyError How to Safely Handle Dictionary Key Access

Table Of Contents

1
The Historical Context of JSX
2
Technical Implementation: JSX Under the Hood
3
Why Not Template Literals or Other Alternatives?

Related Posts

Mastering useRef in React How to Remember Previous Props and State Like a Pro
December 29, 2025
4 min