I continue to implement my most daring ideas, for which there were previously no resources and which can now be realized thanks to the advent of LLM. I believe that now the value of the idea itself has become higher and it is it that decides everything.
Today I want to introduce a lightweight UI framework. It is written in Rust, runs on Windows (x64, ARM), macOS, Linux, Android, iOS/iPadOS, and even in the browser via WASM (online demo on GitHub Pages). Provided with examples of use in Rust, C, C++ and even ASM.
Distinctive feature: the framework has two formats - it either displays a graphical UI for people, or renders the UI in JSON so that AI agents can interact with it without taking screenshots. The same feature made it possible to add the ability to transfer the UI via SSH (more details below).

The key idea is JSON in everything
Although shifting JSONs is the talk of the town, in this case I considered it justified. The simplicity of the protocol, starting from the lower level, allows you not to spend a lot of time learning it, and in this case this is more important than rendering speed (the framework is intended for utilities, not for complex graphics).
The lower level of the framework can only render a JSON frame of 9 primitives. Here they are:
Primitive | Geometry | Properties | Description |
|---|---|---|---|
|
|
| rectangle, including with rounded corners |
|
|
| segment |
|
|
| circle |
|
|
| triangle (arrows, checkmarks) |
|
|
| closed polygon (graph sectors, own figures) |
|
|
| textline; transfer does a layer of screens |
|
|
| picture |
|
|
| group cropped to rectangle (scrolling) |
|
|
| invisible area for mouse and touch (not drawn) |
At a higher level, familiar controls are added to JSON, such as Row, Text, IconButton and others. JSON with complex elements when going down to the lower level will be transformed so that only these 9 primitives remain.
All this made it possible to quickly adapt the framework to all 6 platforms of humanity:
platform | backend |
|---|---|
macOS | AppKit, CoreGraphics, CoreText, ImageIO via Objective-C runtime |
iOS | UIKit, CADisplayLink, same CoreGraphics/CoreText code as on macOS |
Android | JNI manually, |
Windows | Win32, Direct2D, DirectWrite and WIC, COM manually; DPI per monitor, dark header |
Linux | own Wayland and X11 protocol code (xcb), Cairo + Pango, xkbcommon - all through |
Browser |
|
To add a platform, you need to implement 9 methods (one for each of the primitives) using the platform, and also add event processing.
Custom controls
At the highest level, users can add their own controls to JSON like this:
#include <uison_widgets.hpp>
using namespace uison::widgets;
template <class F>
uison::Node Pill(std::string text, F on_click) {
return Box({
.padding = {8, 22},
.fill = uison::json(R"({ state: {
normal: "$theme.primary", hover: "$theme.primaryHover", pressed: "$theme.primaryPressed" } })"),
.radius = 999, // more than half the height: the ends become semicircles
.align = "center",
.interactive = true,
.on_click = on_click,
.child = Text(text, {.bold = true, .color = "$theme.onPrimary"}),
});
}
int main() {
auto screen = Column({.padding = 24, .gap = 16, .cross = "start", .children = {
Text("Pressed {@n} times", {.size = 20}),
Pill("Press me", [](uison::Cx& cx) {
cx.data().set("n", cx.data().get<int>("n") + 1);
}),
}});
uison::Ui ui(screen, {.size = {360, 140}, .data = uison::obj{{"n", 0}}});
return ui.run("Pill");
}
Or directly in JSON:
{
Pill: {
params: { text: "" },
interactive: true, // the node gets hover / pressed states and a click
body: {
Box: {
padding: [8, 22],
radius: 999, // more than half the height: the ends become semicircles
align: "center",
fill: { state: {
normal: "$theme.primary",
hover: "$theme.primaryHover",
pressed: "$theme.primaryPressed",
} },
child: { Text: { text: "$text", bold: true, color: "$theme.onPrimary" } },
},
},
},
}
All these new elements, having reached the bottom layer, will be converted to JSON from the same 9 primitives that are shown in the table above.
We render only what has changed
The new frame is compared with the old one element by element (LCS alignment, groups of clips with the same rectangle are compared internally). Changed, added and removed elements produce areas of “damage”, and the backend redraws only these.
For example, thanks to list virtualization, a mail frame of 2000 letters contains a couple of dozen lines.
How viable is the idea?
Based on the same idea, it was possible to implement even a simple browser. HTML and CSS are converted to JSON, after which the result is simply fed to our framework.
Uison itself does not know anything about HTML and CSS. It receives the familiar JSON and displays it just like the interface of a regular application.
Thus, the same mechanism allows you to draw both regular applications with buttons and tables, and web pages.

stdin and stdout instead of window: UI over SSH
Since we have JSON at the very bottom, we don’t have to render it at all, but send it as is – to the console in its bare form. This allows you to easily run the program on the server and work with it over SSH as if it were running on your computer.
The program on the server does not know about SSH. It writes frames to stdout and reads events from stdin. The server only needs sshd, no X11, no VNC, no browser.
The player can download the program to the server itself and run it with --console.

The player is designed as a separate project. You can even build it for Android and control the program via your phone. In a separate tab you can view JSON events and render frames that are transferred between the client and server:

Development of the idea: mode for AI agents
The same application can run in multiple modes without changing the source code. It can open a regular graphics window for a human, pass JSON frames to an external renderer, or provide a semantic description of the interface to an AI agent.
Launch | Who's on the other end | What goes into stdout |
|---|---|---|
| Man | Nothing: window opens |
| Player that draws | JSON frames: rectangles, text, coordinates |
| Script or AI agent | JSON with meaning: roles, names, states |
| Claude Code and other MCP clients | The same meaning, but in the MCP protocol |
With the --mcp flag, the program becomes an MCP server, that is, a set of tools for Claude Code, Cursor and other AI clients. It can be connected with one command: claude mcp add todo – ./todo --mcp, no need to write any code. The agent calls snapshot and receives the screen as text, and then acts with the click, type, choose tools. The answer is only what has changed. For example, an agent enters “Milk” in the field and presses Enter:
→ {"jsonrpc":"2.0","id":4,"method":"tools/call","params":{"name":"type","arguments":{"key":"draft/1/0","text":"Milk","submit":true}}}
← {"jsonrpc":"2.0","id":4,"result":{"content":[{"type":"text","text":"ok\nchanges (+ added, - removed, ~ changed):\n+ checkbox \"Milk\" #4/0 unchecked\n+ button \"trash\" #del-4\n+ text \"3\"\n+ text \"1 of 4 done\"\n+ text \"Remaining: 3\"\n- text \"2\"\n- text \"1 of 3 done\"\n- text \"Remaining: 2\"\n~ #draft/1/0 focused\n"}],"isError":false}}
The “Milk” item and its delete button appeared in the list, and the counter changed from “1 of 3” to “1 of 4”. The agent will not be able to press an inactive button, just as a person could not: the program will respond that the button is inactive.
Size and speed
I’ll show you using an example of a real open source program – Disk Usage on macOS. It was created in two versions: egui and uison, both in Rust. Here is the test result:
Indicator | egui (original) | uison |
|---|---|---|
Program size, macOS arm64 | 5.1 MB (5,126,464 B) | 0.9 MB (923,216 B), −82% |
Size with | 4.5 MB (4,450,560 B) | 0.9 MB, about 5 times less than |
Dependencies in | 362 | 0 external (uison racks only) |
Empty window memory, no scanning | 122 MB | 55 MB |
Memory after scan | 152 MB | 97 MB, −36% |
Memory peak during scan | 167–176 MB | 183–184 MB |
Strings Rust | 3 198 | 3,547 + 479 lines of JSON screen |
Quick start
Everything is in the lessons in Russian. Lessons for Rust, C, C++, as well as a short introduction to ASM.
Here I will show you how to start using Rust.
Step 1. Create a project and add uison
cargo new hello && cd hello
cargo add uison
Step 2: Replace src/main.rs
use uison::prelude::*;
fn main() {
let screen = center(column().gap(12).cross("center").children([
text("Pressed {@n} times").size(20),
button("+1").key("inc").on_click(|cx| cx.data.edit("n", |n: &mut i32| *n += 1)),
]));
let mut ui = Ui::from_node(screen).with_size(320.0, 200.0);
ui.data.set("n", 0);
run(ui, "Hello");
}
Step 3: launch
cargo run --release
A window with a counter will open. {@n} – data binding: the handler changes n, and the text is updated itself, without manual redrawing.
To keep the program small, add an assembly profile to the end of Cargo.toml:
[profile.release]
opt-level = "s"
lto = true
codegen-units = 1
panic = "abort"
strip = true
Summary and links
The framework does not aim to replace Qt or other full-fledged GUI frameworks. uison is primarily designed for utilities, developer tools, and general applications with buttons, lists, tables, and forms. For games and complex graphics, it is better to use other solutions.
For those interested, everything you need can be found at the following links:
GitHub project repository: uisonlab/uison
Automatic builds (made using GitHub Actions, and this guarantees that the source code is built and not something wrong is downloaded).
SSH player for running the program remotely via SSH: uisonlab/uison-ssh-player
WASM demo on GitHub Pages.
💬 Discussion 0
BBCode & Emoji supportedParticipate in discussions, ask authors questions, and share benchmarks by joining the ProArena engineering community.