Syntax highlighting and formatting for JSX inside HTML script blocks using type="jsx".
- JSX syntax highlighting inside
<script type="jsx">blocks in regular.htmlfiles - Support for
<script type="jsx">,<script type="text/jsx">, and<script type="text/babel"> - Built-in Format Document support powered by Prettier
- Format Selection support
- Snippets for JSX script blocks and React patterns
- Commands to convert between
text/babelandjsx
<script type="jsx">
const App = () => <h1>Hello JSX</h1>;
</script>Open any .html file. The extension activates automatically and highlights JSX inside <script type="jsx"> blocks.
No configuration or language mode changes needed.
Run:
Format Documentor use:
Option + Shift + Fon macOS.
The formatter preserves:
<script type="jsx">It temporarily converts JSX script blocks internally for formatting and restores them back to type="jsx" afterward.
| Command | Description |
|---|---|
HTML JSX Script: Format Document |
Formats the current document |
HTML JSX Script: Insert JSX Script Block |
Inserts a ready-to-use JSX script block |
HTML JSX Script: Convert text/babel to jsx |
Converts Babel script blocks to JSX script blocks |
HTML JSX Script: Convert jsx to text/babel |
Converts JSX script blocks to Babel script blocks |
| Prefix | Description |
|---|---|
jsxscript |
Inserts a <script type="jsx"> block |
jsxroot |
Inserts a React root render snippet |
jsxcomponent |
Inserts a functional JSX component |
jsxapp |
Inserts a small HTML React app structure |
| Setting | Default | Description |
|---|---|---|
htmlJsxScript.formatter.enabled |
true |
Enables the formatter |
htmlJsxScript.formatter.printWidth |
80 |
Formatter line width |
htmlJsxScript.formatter.singleQuote |
false |
Use single quotes |
htmlJsxScript.formatter.trailingComma |
es5 |
Trailing comma behavior |
htmlJsxScript.formatter.bracketSameLine |
false |
Controls multiline JSX closing bracket behavior |
htmlJsxScript.formatter.htmlWhitespaceSensitivity |
css |
Controls HTML whitespace behavior |
Example:
{
"htmlJsxScript.formatter.printWidth": 100,
"htmlJsxScript.formatter.singleQuote": true
}This extension provides editor support only.
It does not transpile JSX in the browser. If you want runtime JSX support in a plain HTML file, you still need Babel Standalone, a build tool, or another JSX transform setup.
https://github.com/romerodiesan/html-jsx-script
MIT
This repository follows a production-oriented workflow:
mainis the stable branch.- Feature work should be done on short-lived branches and merged through Pull Requests.
- Commit messages must follow Conventional Commits.
Examples:
feat(grammar): support jsx and text/jsx script types
fix(formatter): preserve script type=jsx after formatting
docs(readme): document html injection workflowBefore publishing:
npm ci
npm run lint
npm run packageSee CONTRIBUTING.md for full contribution and commit policy.
src/
core/
constants.js
document.js
logger.js
features/
commands/
index.js
formatting/
providers.js
transforms/
scriptTypeTransforms.js
formatter/
index.js
extension.js
syntaxes/
snippets/
samples/Architecture responsibilities:
src/extension.js: composition root and VS Code activation lifecycle.src/core/*: shared low-level utilities.src/features/commands/*: user-triggered commands.src/features/formatting/*: formatting providers.src/features/transforms/*: pure text transformations.src/formatter/*: Prettier integration and JSX script preservation.