
When Large Language Models generate user interfaces, they typically output JSON or plain text that gets parsed and rendered. This approach works—but it's wasteful, verbose, and fundamentally misaligned with how UIs are actually structured.
Enter OpenUI, a full-stack generative UI framework that's quietly accumulating 2.9K GitHub stars by asking a different question: What if we designed a language specifically for streaming UI generation?
The answer is OpenUI Lang—a compact, stream-first structured language that claims up to 67% token efficiency compared to JSON. For teams running AI-powered UI generation at scale, that's not an optimization. It's a paradigm shift.
Traditional LLM UI generation follows this pattern:
{
"type": "container",
"children": [
{
"type": "text",
"content": "Hello World",
"style": { "fontSize": "16px", "color": "#333" }
},
{
"type": "button",
"label": "Click Me",
"onClick": "handleClick()"
}
]
}
This works for small interfaces. But consider what happens when:
JSON was designed for data interchange, not real-time UI streaming. OpenUI Lang was designed from the ground up for exactly this use case.
OpenUI Lang uses a compact, tag-based syntax that can be parsed incrementally as the LLM generates tokens:
<container direction="vertical" gap="16">
<text size="16" color="#333">Hello World</text>
<button variant="primary" onClick={handleClick}>Click Me</button>
</container>
| Principle | Implementation | Benefit |
|---|---|---|
| Stream-first | Incremental parsing, no closing tags required | Render before generation completes |
| Compact syntax | Minimal characters, no quotes for simple values | 67% fewer tokens vs JSON |
| Component-driven | Built-in chart, form, table, layout components | Consistent output, reduced hallucination |
| Extensible | Define custom component libraries | Domain-specific UI generation |
JSON (156 tokens):
{
"component": "Card",
"props": {
"title": "User Profile",
"children": [
{
"component": "Avatar",
"props": { "src": "/image.jpg", "size": "large" }
}
]
}
}
OpenUI Lang (52 tokens):
<Card title="User Profile">
<Avatar src="/image.jpg" size="large" />
</Card>
That's a 67% reduction in token count for identical output.
OpenUI's team published comprehensive benchmarks across 7 common UI patterns. Here's the full breakdown:
| Scenario | JSON Tokens | OpenUI Tokens | Savings |
|---|---|---|---|
| Simple Card | 156 | 52 | 67% |
| Data Table (10 rows) | 892 | 347 | 61% |
| Form with Validation | 1,247 | 489 | 61% |
| Dashboard Layout | 2,103 | 756 | 64% |
| Chart Component | 678 | 234 | 66% |
| Navigation Menu | 445 | 167 | 62% |
| Multi-step Wizard | 1,834 | 623 | 66% |
Average savings: 63.8%
| Scenario | JSON (ms) | OpenUI (ms) | Improvement |
|---|---|---|---|
| Simple Card | 340 | 89 | 74% faster |
| Data Table | 1,240 | 312 | 75% faster |
| Dashboard | 2,890 | 678 | 77% faster |
Because OpenUI Lang can be parsed incrementally, you see 75% faster time-to-first-render on average. The UI starts appearing while the LLM is still generating.
OpenUI isn't just a language—it's a complete stack. Here's the architecture:
┌─────────────────────────────────────────────────────────┐
│ Developer Defines Component Library │
│ - Allowed components (Card, Button, Table, etc.) │
│ - Props schema for each component │
│ - Custom components for domain-specific UI │
└─────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────┐
│ System Prompt Generation │
│ - Auto-generates LLM instructions │
│ - Includes component documentation │
│ - Enforces OpenUI Lang syntax │
└─────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────┐
│ LLM Generates OpenUI Lang (Streaming) │
│ - Compact syntax, token-efficient │
│ - Stream-friendly, parseable incrementally │
└─────────────────────────────────────────────────────────┘
↓
┌─────────────────────────────────────────────────────────┐
│ OpenUI Renderer (Client-side) │
│ - Parses OpenUI Lang in real-time │
│ - Maps to React/Vue/Svelte components │
│ - Handles state, events, validation │
└─────────────────────────────────────────────────────────┘
// Define your allowed components
const componentLibrary = {
Card: {
props: {
title: 'string',
variant: ['default', 'elevated', 'outlined'],
children: 'array'
}
},
Button: {
props: {
label: 'string',
variant: ['primary', 'secondary', 'ghost'],
onClick: 'function'
}
},
// Add custom domain components
ProductCard: {
props: {
productId: 'string',
showPrice: 'boolean',
showReviews: 'boolean'
}
}
};
The framework auto-generates system prompts that instruct the LLM to use only these components with valid props. This dramatically reduces hallucination and ensures renderable output.
We're entering the era of agentic UIs—interfaces that adapt dynamically based on user intent, context, and real-time data. OpenUI Lang is purpose-built for this future.
| Use Case | Why OpenUI Lang Wins |
|---|---|
| Dynamic dashboards | Stream large layouts without waiting for full JSON |
| Conversational UIs | Render responses incrementally as agent thinks |
| Multi-step workflows | Generate complex forms with validation on-the-fly |
| Personalized interfaces | Adapt UI structure per-user without template explosion |
| Real-time data visualization | Stream chart updates as data arrives |
If you're running an AI agent that generates 10,000 UIs per day:
Annual savings: $34,675 for the same output quality.
At enterprise scale (100K+ UIs/day), you're looking at $300K+ annual savings just from token efficiency.
Here's how you actually use OpenUI in a production app:
import { OpenUIRenderer, createComponentLibrary } from '@openui/react';
// 1. Define your component library
const library = createComponentLibrary({
components: {
Card: { props: { title: String, variant: String } },
Button: { props: { label: String, onClick: Function } },
DataTable: { props: { columns: Array, data: Array } }
}
});
// 2. Set up the renderer
const renderer = new OpenUIRenderer({
library,
streaming: true, // Enable incremental rendering
onError: (error) => console.error('Parse error:', error)
});
// 3. Stream LLM output to renderer
async function generateUI(prompt: string) {
const response = await fetch('/api/generate', {
method: 'POST',
body: JSON.stringify({ prompt })
});
const reader = response.body.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const chunk = decoder.decode(value);
renderer.parse(chunk); // Incremental parsing
}
return renderer.render(); // Final rendered UI
}
// The LLM streams OpenUI Lang tokens
// Renderer parses and renders incrementally
// Token 1-20: "<Card title="Dashboard">"
// → Renders card container immediately
// Token 21-50: "<DataTable columns={...}>"
// → Renders table structure, shows loading state
// Token 51-200: Data rows streaming in
// → Table populates row-by-row as data arrives
// User sees progressive rendering, not a blank screen
OpenUI ships with a comprehensive component library:
Container - Flexbox/grid layoutsStack - Vertical/horizontal stackingGrid - Responsive grid systemsSpacer - Whitespace controlTable - Sortable, filterable data tablesChart - Line, bar, pie, area chartsList - Virtualized list renderingCard - Content containers with variantsForm - Validation, submission handlingInput - Text, number, email, passwordSelect - Dropdown with searchCheckbox / Radio - Selection controlsDatePicker - Calendar integrationButton - Multiple variants, loading statesModal - Dialog with backdropTabs - Tabbed navigationAccordion - Expandable sectionsAll components are themeable and support custom styling via props.
OpenUI isn't a universal replacement for all UI generation. Here's when it makes sense:
| Scenario | Why |
|---|---|
| High-volume UI generation | Token savings compound quickly |
| Streaming requirements | Incremental parsing is core strength |
| Agent-driven interfaces | Dynamic, context-aware UIs |
| Cost-sensitive deployments | 60%+ token reduction matters |
| Custom component ecosystems | Domain-specific UI libraries |
| Scenario | Why |
|---|---|
| Static, template-driven UIs | Traditional templating is simpler |
| Visual design-heavy interfaces | Design tools may be better fit |
| Small-scale projects | Token savings may not justify learning curve |
| Non-LLM UI generation | OpenUI Lang is LLM-optimized |
If you're already generating UIs with LLMs:
OpenUI represents a fundamental shift in how we think about LLM-generated interfaces:
For teams building AI agents, dynamic dashboards, or any system that generates UIs at scale, OpenUI Lang isn't just an optimization—it's infrastructure that changes your unit economics.
The 2.9K GitHub stars and rapid adoption suggest the community agrees. When token costs and latency matter, purpose-built languages beat general-purpose formats every time.
Ready to try it? OpenUI is open source at github.com/thesysdev/openui. Documentation and benchmarks available at openui.com.