JSX is a syntax extension for JavaScript that lets developers write markup that looks like HTML directly inside JavaScript code. React’s own documentation describes it as “a syntax extension for JavaScript that lets you write HTML-like markup inside a JavaScript file,” and notes that under the hood this markup is transformed into plain JavaScript objects. React popularized JSX, but the two are technically separate: JSX is a syntax, and React is a library that consumes it.
The formal definition lives in the JSX specification, maintained in the facebook/jsx repository. That specification describes JSX as “an XML-like syntax extension to ECMAScript without any defined semantics.” Crucially, JSX is not meant to be implemented by browser engines, nor is it a proposal to add the syntax to the ECMAScript standard. Instead it is intended to be consumed by preprocessors and transpilers that transform JSX tokens into standard JavaScript.
The specification states that its purpose is to define “a concise and familiar syntax for defining tree structures with attributes,” so that a community of independent parsers and syntax highlighters can conform to a single shared definition. The document is explicit that JSX does not attempt to comply with any XML or HTML specification; the resemblance to XML exists purely for familiarity, while JSX is designed as an ECMAScript feature.
In practice, JSX makes user interface code read like a blend of markup and logic. React’s documentation lays out a small set of rules: a component returns a single root element, every tag must be explicitly closed, and attributes use camelCase names such as className instead of class. These constraints make JSX stricter than HTML, but they let markup and the JavaScript that drives it live together in one place.
Because JSX expressions compile down to ordinary function calls that create element objects, they fit naturally with a component-based architecture and with techniques like a virtual DOM, where the described tree is reconciled against the real document. Although born in the React community, the syntax spread to other libraries and tools, and the standalone specification was written precisely so that any of them could adopt a common, well-defined form of JSX.