January 23, 2026 · 6 min read★ Featured
If content is the heart of your website, the API is its bloodstream. Decoupled frontends like Next.js rely on clean, predictable data structures from the backend. In this post, we’ll explore how Wagtail’s StreamField is serialized, and why understanding this helps you build flexible, modular frontends.
In modern web development, the trend is toward headless or decoupled architectures as I explain in another blog post. Wagtail, with its StreamField content blocks, lets editors build rich, flexible pages. But for a frontend like Next.js, that content must travel in a format the JavaScript layer can understand: JSON. That’s where serialization comes in. Wagtail translates your flexible, nested content blocks into a structured format, which your frontend can then render consistently, no matter the page layout.
Definition
Serialization is the process of turning a complex Python object into a data structure that can be sent over the network, usually JSON for web applications. For StreamField, this means Wagtail converts:
into a format that a frontend framework can parse and render dynamically.
Think of serialization like packing your luggage: the contents are the same, but they need to fit neatly into a suitcase so you can take them anywhere.
Concept
A StreamField is made up of blocks, each with a type and value. When serialized:
type and value keyExample (simplified):
[
{ "type": "heading", "value": "Welcome to Our Site" },
{ "type": "paragraph", "value": "StreamField makes content flexible." },
{ "type": "image", "value": { "url": "/media/banner.jpg", "alt": "Banner" } }
]
This structure allows your frontend to iterate over blocks, render them conditionally, and reorder them as needed without touching the backend.
Think of StreamField JSON like LEGO pieces:
type) and color (value)The backend provides the pieces; your frontend decides the final model.
Concept
StreamField isn’t limited to simple text or images. It can handle structured, rich content blocks. A great example is a callout block, often used to highlight important information, tips, warnings, or examples. Think of a callout block as a highlighted box in your content toolkit. Editors can customize:
The Wagtail StructBlock allows these fields to live together as a single, coherent unit.
When serialized for the API, Wagtail transforms a callout into a structured JSON object that keeps all relevant information intact. Example:
{
"type": "callout",
"title": "Pro Tip",
"content": "<p>Always validate user input before saving.</p>",
"style": "tip",
"icon": "✅"
}
This structure is clean, predictable, and ready for a frontend to render consistently.
Think of callout blocks like sticky notes on a whiteboard:
Even if the page layout changes, the callout retains its identity, just like a sticky note keeps its message visible regardless of its position.
Concept
StreamField can also handle detailed, multi-field content, like a resume experience section. An Experience Block allows editors to define:
This block is ideal for structured content where multiple fields must be kept together and serialized for consistent API use.
Example JSON serialization (generic content):
{
"type": "experience",
"role": "Role Title",
"company": "Company Name",
"location": "Location",
"startYear": "Start Year",
"endYear": "End Year",
"description": "<p>Job description or responsibilities.</p>"
}
This structure keeps all the details in one object, making it easy to render consistently and reuse across pages or profiles.
Think of an Experience Block like a profile card in a portfolio:
Subsection: Important Points
Serialization brings clear advantages for frontend developers:
This separation allows marketing teams to update content freely, while developers maintain predictable rendering.
The key challenge is giving editors freedom while maintaining design integrity.
Serialization gives a contract between backend and frontend: editors fill the blocks, developers decide the rules for rendering.
A simple rule: each block type should correspond to one reusable component. If a block behaves differently in multiple places, consider separate block types.
type and value for predictable renderingReach out via the contact form or connect on Linkedin!