JSX
In one line
JSX is a syntax extension for JavaScript that lets you write HTML-like markup directly inside your JavaScript code.
In simple words
JSX (JavaScript XML) is a syntax extension that makes writing React components feel like writing HTML. Instead of calling React.createElement() dozens of times, you write familiar tags like <div>, <h1>, and <button> right inside your JavaScript.
Under the hood, JSX is compiled to React.createElement() calls by tools like Babel or the TypeScript compiler. A line like <h1>Hello</h1> becomes React.createElement('h1', null, 'Hello'). You never write this by hand — JSX is purely a developer convenience.
JSX is not valid JavaScript on its own; it must be compiled. Inside JSX you can embed any JavaScript expression by wrapping it in curly braces {}, which makes it powerful for dynamic content.
Example
const name = "Ada";
const element = <h1>Hello, {name}!</h1>;
// The above compiles to:
// const element = React.createElement("h1", null, "Hello, ", name, "!");The curly braces embed the JavaScript variable name into the JSX markup. Babel transforms the JSX into a createElement call.
Common confusions
Confused with: html
The difference: JSX looks like HTML but it is JavaScript. Tags must be closed (self-closing or paired),
classbecomesclassName, andforbecomeshtmlForbecause these are reserved words in JS.
Related terms
Related Resources
Related Lessons
- JSX Basics
Learn JSX syntax, expressions, and compilation.
Decode error messages
Plain-English explanations of common errors — what they mean, why they happen, and how to fix them.