See it in action

Paste any JSX or HTML — watch it compress in real time.

Input JSX
Aimata DSL

Three steps, one pipeline

Parse

Your JSX or HTML is tokenized and walked into a lightweight AST — no Babel, no external parsers.

parse(source) → ASTNode[]

Compress

The AST is serialized into the bracket micro-DSL. Tags, IDs, classes, props, and children — all encoded losslessly.

compressToDSL(code) → string

Expand

Expand back to production React JSX or plain HTML. Deterministic — compress → expand → compress gives identical DSL.

expandFromDSL(dsl, 'react' | 'html')

The notation

[button#submit-btn.px-4.py-2.bg-blue-500.text-white{onClick=handleClick,type=submit}|Submit]
PartSyntaxExampleNotes
Tagtag[div|...]Any HTML tag or PascalCase component
ID#id[div#hero|...]Maps to id="" attribute
Classes.cls1.cls2[div.flex.gap-4|...]Dot-separated, full Tailwind supported
Props{k=v,k2=v2}{onClick=fn,type=submit}Comma-separated key=value pairs
Children|...|text or [nested]Text or nested DSL nodes

Full API

compressToDSL(code: string): string

Converts JSX or HTML source into Aimata micro-DSL notation. Accepts any well-formed JSX/HTML string.

import { compressToDSL } from '@aimata-dsl/core';

compressToDSL('<div className="flex gap-4">Hi</div>');
// → '[div.flex.gap-4|Hi]'
expandFromDSL(dsl: string, target?: 'react' | 'html'): string

Expands micro-DSL back to JSX or HTML. React mode uses className/{fn}. HTML mode uses class/data-on*.

import { expandFromDSL } from '@aimata-dsl/core';

expandFromDSL('[button.btn{onClick=go}|Click]', 'react');
// → '<button className="btn" onClick={go}>Click</button>'

expandFromDSL('[button.btn{onClick=go}|Click]', 'html');
// → '<button class="btn" data-onclick="go">Click</button>'
parse(source: string): ASTNode[]

Tokenizes and parses JSX/HTML into a plain-object AST. Useful for custom analysis, class extraction, or tooling.

import { parse } from '@aimata-dsl/core';

const [root] = parse('<div className="flex"></div>');
root.tag;     // 'div'
root.classes; // ['flex']
compile(ast: ASTNode[], opts?: { target: 'dsl' | 'react' | 'html' }): string

Compiles an AST directly to any target. Skips the parse step when you already have an AST from parse().

import { parse, compile } from '@aimata-dsl/core';

const ast = parse('<nav className="flex"></nav>');
compile(ast, { target: 'dsl' });   // '[nav.flex]'
compile(ast, { target: 'html' });  // '<nav class="flex"></nav>'

The ecosystem

@aimata-dsl/ui
◌ Coming soon

Token-optimized React component primitives. Every component exposes a DSL signature for tooling, AI prompts, and structured component compression across more complex UI systems.

◌ Button, Card, Input ◌ .dsl introspection ◌ Tailwind variants
@aimata-dsl/mcp-server
◌ Coming soon

MCP-compatible HTTP server. Register the project compression workflow as a tool in Claude, Gemini, or any MCP-enabled AI assistant for form-heavy and component-heavy UI work.

◌ POST /compress ◌ POST /expand ◌ GET /manifest

Built for AI workflows

AI Prompt Compression

Send DSL to your LLM instead of raw JSX — 2-3× fewer tokens, lower cost, same information.

// Compress before sending to AI
const prompt = `Edit: ${compressToDSL(myUI)}`;

// Expand AI's DSL response
const updated = expandFromDSL(aiReply, 'react');

Design Token Extraction

Parse any component and extract all classes, IDs, and props programmatically.

const [root] = parse(myComponent);
const tokens = root.classes;
// ['rounded-xl', 'shadow-lg', 'p-6', ...]

Cross-Framework Output

Write once in DSL, export to any framework. React, plain HTML, and more targets coming.

const dsl = compressToDSL(reactComp);
expandFromDSL(dsl, 'react');  // JSX
expandFromDSL(dsl, 'html');   // HTML

Ready to compress?

Try the interactive Studio or install the package right now.

npm install @aimata-dsl/core