What Is Div Data in Generative UI?
Div data is a structured JSON representation of layout containers and content blocks that a server or AI model emits for a dynamic UI renderer, instead of…

Div data is a structured JSON representation of layout containers and content blocks that a server or AI model emits for a dynamic UI renderer, instead of sending arbitrary code or free-form text. It describes the “what” and “where” of a screen—sections, grids, text, images, inputs, overlays—in a machine-readable format that a native client (like a SwiftUI app) can safely transform into real UI.
How Div Data Works
In the DivKit world, div data is the root JSON structure for a card or screen. It includes required fields like log_id and states, and can optionally define functions, timers, variables, and a div payload that describes layout blocks such as containers, grids, galleries, inputs, and tabs.
That makes div data an ideal mental model for generative UI. Instead of an LLM responding with prose, it responds with div-style JSON layout that encodes:
- Structure: nested containers, rows, columns, overlays, and grids.
- Content: text, images, icons, buttons, inputs.
- Behavior: states, visibility conditions, timers, and interactive actions.
DivKit’s documentation explicitly frames JSON as carrying positioning, design, and interactivity information, plus states and variables for changing UI on the fly. On iOS, the framework can accept a dictionary, Data, or a DivData root structure as its rendering input, showing how well div data fits into a server-driven UI pipeline.
For generative UI, the same pattern applies: the server or AI engine emits div-style JSON; the client decodes it into types; a renderer turns those types into native views.
Why Div Data Matters for Uzori Users
For Uzori’s audience—iOS teams building AI-native interfaces—div data matters because it’s the bridge between LLM intent and SwiftUI layout. It gives AI something structured to emit, and gives SwiftUI something safe to render.
Uzori’s core idea is “JSON schema first, SwiftUI second.” OpenAI’s Structured Outputs feature shows why this matters: their benchmarks report 100% reliability for gpt-4o-2024-08-06 in matching developer-supplied JSON Schemas, versus less than 40% for older models like gpt-4-0613. That level of reliability means we can treat div-style JSON as a contract, not a best-effort guess.
When Uzori’s engine generates UI, it doesn’t emit free-form SwiftUI code. Instead, it emits JSON that conforms to a constrained schema:
- A root screen or card type (similar to DivKit’s
div-data). - Containers with layout properties (stacking, spacing, alignment).
- Blocks for text, image, button, form field, gallery, tab, or overlay.
- Stateful elements that can switch variants based on user actions.
The Uzori iOS SDK then decodes this JSON into Swift types using Codable, and ties them into SwiftUI using Observation (available from iOS 17). This keeps the UI native and type-safe, while still letting AI “design” screens on the fly.
Mapping Div-Style JSON to Type-Safe SwiftUI View Models
The key move for Uzori users is to treat div data as layout intent, not as UI code. You map that intent into a small, carefully designed set of SwiftUI view models.
A typical flow looks like this:
- Server validates JSON
Uzori’s engine generates div-style JSON from a user request plus your backend APIs. Your server validates the payload against a JSON Schema that defines allowed layout types, properties, and actions. - Swift decodes into typed models
On iOS, you expose a root type, e.g.:struct Screen: Codable { let id: String let states: [ScreenState] let root: DivNode } enum DivNode: Codable { case container(ContainerProps) case text(TextProps) case image(ImageProps) case button(ButtonProps) case overlay(OverlayProps) // ...other cases }Swift’sCodable,Equatable, andHashablegive you a stable, inspectable model that you can diff, cache, and unit test. - SwiftUI renders from view models
You implement a renderer that takesDivNodeand returns native SwiftUI views:@ViewBuilder func render(_ node: DivNode) -> some View { switch node { case .container(let props): ContainerView(props: props) case .text(let props): TextView(props: props) case .image(let props): ImageView(props: props) case .button(let props): ButtonView(props: props) case .overlay(let props): OverlayView(props: props) } }Observation ensures only views whosebodyreads changed properties are updated, which is critical when Uzori streams new layout fragments or state changes during a conversational flow. - Layout constraints prevent chaos
Because your schema and enums define exactly which layout types exist—and which properties each can use—AI cannot invent random layout primitives. You keep control over alignment, spacing, typography, and component reuse.
This pattern is what turns “div-style JSON UI” into typed native UI, for real-world iOS apps. Instead of hand-coding every wizard, comparison view, or concierge flow, you let Uzori generate div data and rely on your renderer to keep everything consistent with your design system.
Why Div Data Is a Guardrail, Not a Limitation
Some engineers worry that div data will constrain creativity. In practice, div data is the guardrail that makes generative UI shippable.
Without a schema, an LLM can emit malformed JSON, inconsistent properties, or layouts your client can’t render. With div data:
- The model is forced to speak in your design language: containers, blocks, overlays.
- You can validate every screen server-side before it reaches the device.
- You can version the schema over time without breaking older clients.
DivKit’s maturity demonstrates this pattern’s stability. With roughly 2.7k stars and about 5,600 commits on GitHub—and recent releases like 33.7.0—DivKit shows that schema-driven layout contracts can evolve and scale across platforms. Uzori applies the same principle to AI-native SwiftUI, focusing on one platform and one rendering stack.
For overlay-heavy designs—hero images with badges, timers, labels, and stacked actions—div data becomes especially powerful. You can represent complex “div on image” layouts as structured JSON and map them to SwiftUI overlays without losing control of touch targets or accessibility; the related guide on translating overlay-heavy media UI to native SwiftUI digs into this in more detail.
Related Terms and Common Confusions
Div data often gets confused with several adjacent concepts. Clarifying these helps you choose the right pattern for your app.
- Server-driven UI (SDUI):
SDUI describes the overall pattern of servers sending layout descriptions to clients. Div data is one concrete format for SDUI; Uzori extends it with AI-driven generation and SwiftUI-native rendering. - Remote code execution:
Div data is not remote code. It’s a data contract. The client decides how to interpret each block using local, vetted SwiftUI components, avoiding security risks from arbitrary code. - Generic LLM chat UI:
A chat box shows free-form text and maybe some rich replies. Div data describes entire screens. Uzori uses div-style JSON so AI does not just “answer”—it orchestrates multi-step flows, navigation, and rich product views. - HTML or web layout:
Div data might sound like HTML’s<div>tag, but the intent is different. HTML targets browsers; div data targets native layout renderers. In Uzori’s case, that renderer is a SwiftUI view hierarchy tuned for iOS.
The important distinction for iOS engineers is untyped remote UI vs typed native UI. Div data lives firmly on the typed side: it is JSON designed to become Swift models.
A Concrete Example: AI Concierge for Roaming Protection
Consider an iOS team shipping an AI concierge to help users configure roaming protection. You want the assistant to move beyond chat and present:
- A comparison table of roaming packages.
- Image-backed cards for each destination.
- A multi-step wizard to confirm choices and payment.
With Uzori, the assistant doesn’t respond with three paragraphs of text. Instead, it emits div data like:
{
"log_id": "roaming-concierge-001",
"states": [ ... ],
"div": {
"type": "container",
"layout": "vertical",
"children": [
{ "type": "text", "role": "title", "value": "Choose your roaming plan" },
{ "type": "grid", "columns": 2, "items": [ /* plan cards */ ] },
{ "type": "wizard", "steps": [ /* confirmation steps */ ] }
]
}
}
Your server validates this JSON against the schema. The Uzori SDK decodes it into Swift types. Your renderer then produces native SwiftUI screens:
- A title using your app’s text styles.
- A grid rendered with
LazyVGrid, showing cards for each roaming plan. - A wizard flow composed of native
NavigationStacksteps.
When the user tweaks inputs, Uzori streams updated div data, possibly switching states or adding comparison blocks. Observation ensures only affected pieces re-render; the rest of the screen stays stable.
The result is a concierge that feels like your app, not like someone else’s chatbot. You’ve compressed weeks of UI iteration into a streaming, AI-driven interface, while keeping everything native and safe. If you want to experiment with this pattern in your own iOS app, you can connect your backend and OpenAPI descriptions to Uzori’s engine via the iOS SDK described at uzori.ai.