Div data in generative UI: structuring AI output for safe SwiftUI rendering

Div data is the contract between your LLM and your SwiftUI renderer: a structured JSON payload that describes content blocks, layout hints, and actions—not…

Low-angle view of a layered rock face with a central ridge symbolizing structured div data for SwiftUI.

Div data is the contract between your LLM and your SwiftUI renderer: a structured JSON payload that describes content blocks, layout hints, and actions—not arbitrary code or raw prose. When you treat div data as a schema-first UI spec, your backend can safely validate and normalize AI output into predictable SwiftUI sections and components.

This article explains what "div data" really means in generative UI, why schema-first contracts are critical for iOS, and how Uzori’s approach keeps AI-native screens safe, native, and maintainable.

What iOS teams really mean by “div data” in generative UI

In generative UI discussions, "div data" almost never refers to HTML <div> elements.

Teams use div data to mean a JSON UI spec that describes:

  • Content blocks (text, images, video, lists)
  • Layout hints (sections, stacking, spacing, overlay relationships)
  • Actions (taps, navigations, form submissions)
  • State (variables, timers, conditional visibility)

DivKit formalizes this with a div-data root object containing:

  • Global UI states and variables
  • Functions and timers
  • A nested div tree representing content and layout

Uzori’s own demo language mirrors this pattern with blocks like:

  • div_text for copy and headings
  • div_image for product images and thumbnails
  • div_video for playable media

The key point: div data is a declarative description of a UI surface, not an imperative script.

Once you adopt that mental model, LLM-generated UI JSON stops being "weird AI output" and becomes a contract your backend can validate and your SwiftUI renderer can trust.

Why div data matters for SwiftUI and LLM-generated UI JSON

SwiftUI is already declarative and component-based.

Apple describes it as a system where:

  • Views and controls are composed from data
  • Layout structures express hierarchy and intent
  • Data flows from models into views

That maps almost perfectly onto div data:

  • Div blocks → SwiftUI views (Text, Image, VideoPlayer, List)
  • Layout hints → VStack, HStack, ZStack, Section
  • Actions → Button handlers and navigation destinations

When LLMs emit LLM-generated UI JSON instead of prose, you can:

  • Normalize AI output into a stable set of SwiftUI components
  • Avoid rendering arbitrary HTML or remote code
  • Keep performance and accessibility consistent with the rest of your app

In practice, this means:

  • A concierge flow becomes a sequence of div_text + div_form blocks
  • A product explorer becomes div_image carousels and comparison cards
  • A media-heavy screen becomes div_video and div_on_image overlays

All of these can be rendered with safe SwiftUI rendering of AI output—as long as the div data is structured and validated.

Schema-first div data vs. prompt-only formatting

Prompt-only formatting ("please respond in JSON") is brittle.

OpenAI’s Structured Outputs eval shows this clearly:

  • gpt-4o-2024-08-06 achieved 100% schema adherence on a complex JSON Schema test
  • gpt-4-0613 scored under 40%, even with careful prompt engineering

The lesson for iOS teams:

  • Schema-first UI contracts beat prompt-only formatting
  • JSON Schema gives you a reliable trust boundary for AI-generated UI

Generative UI standards like A2UI and OpenUI now recommend the same pattern:

  1. Generate JSON from the model
  2. Validate against a schema
  3. Correct or reject invalid payloads
  4. Stream valid chunks to the client

Uzori follows this pattern for Uzori schema-first div data contracts:

  • A typed, allowlisted tool registry controls backend access
  • SwiftUI screens are described with a constrained div schema
  • Every AI-generated payload is validated server-side before rendering

The result: you get non-chat generative UI structured responses that your app can render safely, instead of parsing prose and hoping it looks right.

How Uzori structures div data for safe SwiftUI rendering

Uzori’s iOS SDK wraps this schema-first approach into a single SwiftUI screen.

Under the hood, the flow looks like this:

  1. User intent in
    • Voice or text request from your app
    • Context + session state
  2. Backend orchestration
    • LLM plans the flow using a tool registry
    • Calls your backend APIs (often described via OpenAPI)
  3. Div data generation
    • Model emits LLM-generated UI JSON using a div schema
    • Blocks like div_text, div_image, div_list, div_form compose the screen
  4. Server-side validation & normalization
    • JSON is validated against a schema (required fields, types, ranges)
    • Invalid UI is corrected or rejected
    • Layout hints are normalized into predictable patterns
  5. Streaming SwiftUI screens SDK
    • Validated div data is streamed to the app
    • SwiftUI views are composed on the fly from the JSON spec

Because the schema is contract-first:

  • The client never executes arbitrary code
  • The backend can enforce business rules and design constraints
  • The SwiftUI renderer can be simple, deterministic, and testable

Normalize AI UI responses into SwiftUI components

The biggest practical win of div data is normalization.

Without a schema, each AI response is a bespoke layout.

With schema-first div data, you can:

  • Map each div block to a known SwiftUI view
  • Map each layout hint to a known container or modifier
  • Apply your design system consistently across AI-generated screens

A typical normalization pipeline might:

  1. Parse div data into an internal model
    • DivText, DivImage, DivVideo, DivSection, DivList, etc.
  2. Apply layout rules
    • Convert layout hints to VStack/HStack/ZStack and Section
    • Enforce padding, alignment, typography tokens
  3. Resolve actions
    • Map div actions to typed intents (.navigate, .submitForm, .openURL)
  4. Render SwiftUI
    • A renderer that switches on block type (e.g., switch divBlock → Text, Image, VideoPlayer)

This is how you validate and normalize AI output for iOS:

  • The AI describes what should be on screen
  • Your schema and renderer decide how it appears as native SwiftUI

This approach scales.

Once you’ve implemented a renderer for your div schema:

  • New AI flows don’t require new SwiftUI code
  • A/B tests become schema tweaks instead of client rewrites
  • You can roll out new layouts by evolving the schema and renderer together

Server-driven UI iOS frameworks vs. generative UI

Div data sits at the intersection of:

  • Server-driven UI iOS frameworks (DivKit-style JSON layouts)
  • Generative UI (LLM-driven, intent-based interfaces)

Traditional SDUI systems like DivKit give you:

  • JSON-described cards and templates
  • Variables and state-based UI changes
  • Cross-platform rendering for iOS/Android/web

But they are not LLM-native.

You still design and author each layout by hand.

Generative UI frameworks add:

  • LLMs that compose layouts from user intent and backend data
  • Streaming-first pipelines for progressive screen rendering

The risk is unstructured, unsafe output—unless you introduce div data and schemas.

Uzori’s position is clear:

  • Generative UI, server-driven safety
  • AI composes screens from div blocks
  • Your server validates every screen before it hits the device

This makes Uzori feel familiar to teams already using SDUI, but with:

  • Much richer, adaptive flows
  • Far less manual layout authoring

Generate native iOS UI from LLM responses (without chat boxes)

Most teams start with a chat UI for AI.

The limitations are obvious:

  • Long paragraphs of text instead of real controls
  • Poor alignment with your existing navigation and design system
  • Hard-to-test, hard-to-measure flows

With schema-first div data, you can generate native iOS UI from LLM responses instead:

  • AI doesn’t answer with text only
  • It responds with a JSON UI spec the app can render

Examples of non-chat generative UI structured responses:

  • A roaming plan assistant that returns a multi-step form with div_section blocks
  • A dress finder that returns div_image grids, filters, and comparison cards
  • A configuration wizard rendered as div_stepper + div_summary before commit

Uzori’s iOS SDK makes this a one-screen integration;

  • You mount a single SwiftUI view
  • It connects to a backend endpoint that serves validated div data
  • The SDK streams SwiftUI screens live as the AI generates the UI

From the user’s perspective, this is just your app—but with an interface that designs itself.

Validating AI-generated UI JSON: practical guardrails

The most important question for iOS leads is: how do we validate AI-generated UI JSON in practice?

A robust validation pipeline should include:

  1. Schema validation
    • Enforce types (string, number, enum)
    • Enforce required fields for each block type
    • Limit permitted values (e.g., allowed actions, component IDs)
  2. Business rules
    • Ensure only allowed backend operations are exposed
    • Enforce pricing, availability, and compliance constraints
  3. Design-system constraints
    • Map arbitrary font sizes to tokenized variants
    • Map arbitrary spacing to allowed scale steps
    • Reject layouts that violate accessibility rules (e.g., tap targets)
  4. Error-handling and correction
    • Auto-correct minor schema violations where possible
    • Gracefully degrade to fallback layouts when necessary

Modern standards like A2UI and OpenUI also emphasize:

  • No arbitrary code execution across trust boundaries
  • Flat, streaming JSON so LLMs can build UIs incrementally

Uzori builds these guardrails into its backend contract, so your client sees only safe SwiftUI rendering AI output it can trust.

Div data, streaming-first UI, and trust boundaries

Streaming-first UI is quickly becoming the default pattern.

Industry efforts show this clearly:

  • A2UI uses JSON Lines / streaming JSON messages
  • OpenUI describes itself as "streaming-first"
  • Uzori explicitly says interfaces appear progressively as the answer generates

Combined with schema-first div data, streaming gives you:

  • Faster perceived latency
  • Progressive disclosure of complex flows
  • Clear trust boundaries: validate each chunk before rendering

OpenUI’s GitHub (13.1k stars, 871 forks, 1,058 commits) and A2UI’s v1.0 candidate release (updated June 8, 2026) show that this is not just theory.

Native renderers are the differentiator.

Uzori leans into this by targeting SwiftUI directly, rather than generic web renderers.

Related: div on image overlays in SwiftUI

Many real-world div data payloads include div on image layouts—text and controls overlaid on media.

If you’re converting overlay-heavy media UI to SwiftUI, see this related deep dive:

It covers how to translate div images, badges, and actions into ZStack overlays while keeping your schema and renderer straightforward.

Where Uzori fits in your stack

Uzori is designed as an AI interface layer for native iOS teams:

  • Works with your existing backend and OpenAPI descriptions
  • Composes SwiftUI views from validated div data
  • Streams adaptive interfaces into a single SwiftUI screen

Instead of adopting a new cross-platform framework, you:

  • Keep your SwiftUI architecture, navigation, and state management
  • Add a single Uzori-powered screen
  • Let AI orchestrate flows using your data and design system

For teams exploring schema-first div data contracts and generative UI, Uzori’s docs at uzori.ai are a good reference implementation of these ideas.

FAQ: div data, schema-first UI, and SwiftUI

What is "div data" in the context of generative UI?

Div data is a structured JSON payload that describes a UI surface—content blocks, layout hints, actions, and state—rather than code.

It usually has a root div-data object with nested div blocks like text, images, lists, and forms.

This matches how server-driven UI frameworks such as DivKit and generative UI specs like Uzori’s demo language represent screens.

Why is schema-first div data important for SwiftUI?

SwiftUI expects predictable, typed data flowing into views.

Schema-first div data:

  • Ensures the LLM’s JSON output matches a contract your backend can validate
  • Prevents arbitrary or unsafe UI from reaching the client
  • Lets you map div blocks cleanly onto SwiftUI components (Text, Image, List, etc.)

Without a schema, you’re left rescuing malformed JSON and inconsistent layouts at runtime.

How does Uzori validate AI-generated UI JSON?

Uzori uses a typed, allowlisted tool registry and a server-validated div schema:

  • AI output must conform to a div data contract
  • Backend validation checks types, required fields, and allowed actions
  • Invalid or unsafe payloads are corrected or rejected before streaming

This keeps SwiftUI rendering straightforward and eliminates arbitrary remote code execution.

Can div data work with existing server-driven UI iOS frameworks?

Yes.

If you already use server-driven UI (e.g., DivKit), you can:

  • Extend or adapt your current JSON schema to be LLM-friendly
  • Introduce schema validation for AI output
  • Add a generative step that composes screens from your existing components

Uzori effectively provides this generative layer specifically optimized for SwiftUI.

How do we avoid chat-style UI payloads and build richer AI flows?

Stop asking the model for prose answers and start asking for JSON UI specs.

Define a div schema that includes:

  • Text blocks, forms, lists, carousels
  • Overlays (div_on_image), sections, and multi-step flows

Then:

  • Use Structured Outputs or tool calls to enforce that schema
  • Validate and normalize the resulting div data on your backend
  • Render the blocks as native SwiftUI views instead of chat bubbles

This turns AI into a UI composer, not a text generator.

← All posts