# jsx-notation [Health: Active]

**Category:** 💻 Developer Tools  
**Repository:** https://github.com/SebastianMaciel/jsx-notation  
**GitHub Stars:** 0  
**npm Downloads (last month):** 253  
**Views:** 0  
**Installs:** 0  
**Upvotes:** 0  
**Directory Page:** https://allmcps.com/mcp/jsx-notation

## Description
JSXN encoder/decoder — compact notation for React/Next.js files, optimized for LLMs

## Tools
Capabilities this server exposes over MCP:

- **read_jsxn** — Reads a React/Next.js file (.jsx, .tsx, .js, .ts), HTML file (.html), or SVG file (.svg) from disk and returns its JSXN-compressed representation (~40% fewer tokens). Use this instead of reading JSX/TSX files directly when you need to understand component structure, props, and rendering logic. For full files with imports/hooks/logic, the file-level encoding is used automatically. For .html and .svg files, the HTML encoder is used.
- **encode_jsxn** — Encodes raw JSX/TSX source code or HTML into JSXN compact notation (~40% fewer tokens). Use "snippet" mode for JSX fragments (just the template). Use "file" mode for complete React/Next.js files with imports, types, hooks, etc. Use format "html" to encode HTML source.
- **decode_jsxn** — Decodes JSXN compact notation back into standard JSX/TSX or HTML source code. Use "snippet" mode for JSXN body fragments (just the template). Use "file" mode for complete JSXN files with imports, types, hooks, etc. Use format "html" to decode to HTML output.
- **write_jsxn** — Decodes JSXN notation and writes the resulting JSX/TSX or HTML to a file on disk. Creates parent directories if needed. Writes to .jsx/.tsx/.js/.ts/.html/.svg files. For .html and .svg files, decodes with HTML format (class attrs, void elements, SVG self-closing, etc.).

## JSXN Format Reference

JSXN is a compact notation for React/Next.js code that saves ~40% tokens.

### File-level headers
- `@I module: default Name, x, y` → `import Name, { x, y } from "module"`
- `@I "styles.css"` → `import "styles.css"`
- `@T module: Type1` → `import type { Type1 } from "module"`

### Directives
- `"use client"` / `"use server"` → passed through as-is

### Types
- `Name { field: Type }` → `interface Name { field: Type }`
- `Name = Type | Other` → `type Name = Type | Other`

### Function blocks
- `export default Name(params)` → function signature
- `@state count = 0` → `const [count, setCount] = useState(0)`
- `@ref inputRef = null` → `const inputRef = useRef(null)`
- `name = useHook(args)` → `const name = useHook(args)`
- `variable = expr` → `const variable = expr`
- `let variable = expr` → preserved as `let`
- `---` → separator; everything after is the JSX return body

### JSX body notation
- **Alias headers** (optional): `@C Button=B`, `@P onClick=k`, `@S items-center=ic`
- **Elements**: `tag.class1.class2#id {prop:val, flag} "text"` or `(expr)`
- **Implicit div**: `.className` (div is omitted when it has selectors)
- **Nesting**: 1-space indentation per level
- **Fragments**: `_` → `<>...</>`
- **Conditionals**: `?cond > Element` → `{cond && (<Element />)}`
- **Ternaries**: `?cond > A | B` → `{cond ? (<A />) : (<B />)}`
- **Maps**: `*items > Element` → `{items.map(item => (<Element />))}`
- **Text nodes**: `"Hello"` → raw text
- **Expressions**: `(expr)` → `{expr}`
- **Props**: `{key:value}` string for HTML attrs, `{key:expr}` expression otherwise
- **Boolean props**: `{disabled}` → `disabled`
- **Spread**: `{...props}` → `{...props}`
- **Self-closing**: element with no children → `<Element />`
- **Member expressions**: `Form.Input` (dot after uppercase = member, not class)

### Example
```
@C Modal=M, Button=B
@P onClick=k, disabled=x

M {isOpen:show, onClose:handleClose}
  .modal-body
    h2 (title)
    ?error > Alert {type:error} (error)
    ul.item-list
      *items > li.item {key:item.id, k:()=>select(item)}
        (item.name)
    B {x:!selected, k:handleSubmit} "Confirm"
```

## Claude Desktop Quick Installation
Install path detected from listing signals. Uses `npx` (confidence: high):

```json
"mcpServers": {
  "jsx-notation": {
    "command": "npx",
    "args": ["-y","jsx-notation"]
  }
}
```

## Documentation

## What jsx-notation does

The jsx-notation MCP server converts JSX, TSX, HTML, and SVG source into JSXN, a shorter representation intended for AI and LLM workflows. It reduces repeated closing tags, common attributes, component names, properties, and CSS classes by using indentation, selectors, aliases, and compact property syntax.

For JSX and TSX, JSXN can represent components, text, expressions, boolean properties, spreads, conditional rendering, mapped lists, fragments, imports, state declarations, refs, and other file-level constructs described by the notation reference. HTML and SVG use related syntax, with handling for HTML class attributes, SVG attributes, void elements, XML-style self-closing elements, and quoted comma-containing values.

## How it works

The server communicates over MCP and exposes four operations. `read_jsxn` accepts a local file with a `.jsx`, `.tsx`, `.js`, `.ts`, `.html`, or `.svg` extension and returns its JSXN encoding. `encode_jsxn` converts source supplied as a string, using either file or snippet mode and a JSX or HTML format. `decode_jsxn` turns JSXN back into JSX/TSX or HTML. `write_jsxn` decodes JSXN and writes the result to a file, choosing HTML output automatically for `.html` and `.svg` destinations.

Alias headers can shorten recurring components, props, and CSS classes. JSXN also uses indentation in place of closing tags, CSS-like `.class` and `#id` selectors, and compact forms for expressions and control-flow patterns. When decoding as HTML, attributes become strings and `class` is used instead of JSX's `className`.

## Setup and configuration

Claude Code can register it with `claude mcp add jsx-notation -- npx jsx-notation`. VS Code, Cursor, Windsurf, Cline, Continue, Amazon Q, and JetBrains IDEs use an `mcpServers`-style command configuration, while Zed uses `context_servers`. VS Code's example places the configuration in `.vscode/mcp.json`; Cursor and Windsurf use their respective MCP configuration files.

Restart the client after adding the server. If Cursor cannot find `npx`, use the full path returned by `which npx`. No environment variables are documented as required. For direct application use, install the npm package and use its exported `encode`, `encodeFile`, `encodeHTML`, `decode`, and `decodeFile` functions.

## Tools and capabilities

The jsx-notation MCP server supports these tool workflows:

- Read supported local source files in compact JSXN form.
- Encode raw JSX, HTML, or related source strings.
- Decode JSXN into JSX/TSX or HTML.
- Write decoded output to a destination file.
- Represent React patterns such as conditional children, mapped lists, and fragments.
- Compress recurring component, property, and Tailwind-style class names through aliases.

A project instruction in `CLAUDE.md` or `.cursorrules` can tell an assistant to use `read_jsxn` when gathering context from supported files.

## Limitations and notes

The jsx-notation MCP server only accepts the six documented file extensions and imposes a 10 MB file-size limit. JSXN is described as experimental and lossy, so encoded output may omit semantic details from the original code. The project does not guarantee encoding accuracy, behavior of AI systems consuming the notation, or suitability for a particular use case.

The MCP component reads files from the local file system, so its configuration determines which files the client can expose to it. HTML decoding differs from JSX decoding: values are strings, void elements use HTML syntax, SVG elements without children use XML self-closing syntax, and empty non-void elements are emitted with separate opening and closing tags. The software is provided under the MIT License without warranty.

_Full upstream README: https://allmcps.com/mcp/jsx-notation/readme_

