Adobe AEM
All tools

Developer Tool

AEM Content Fragment Model Generator.

Define your fields once and generate an AEM Content Fragment Model (.content.xml), a sample GraphQL query, a JSON spec, and authoring docs — a companion to the AEM Component Generator. Runs entirely in your browser. How to use

Start from a preset
Fields (8)
.content.xml
<?xml version="1.0" encoding="UTF-8"?>
<jcr:root xmlns:jcr="http://www.jcp.org/jcr/1.0" xmlns:nt="http://www.jcp.org/jcr/nt/1.0"
    xmlns:cq="http://www.day.com/jcr/cq/1.0" xmlns:sling="http://sling.apache.org/jcr/sling/1.0"
    jcr:primaryType="cq:Template"
    jcr:title="Article"
    jcr:description="Editorial article content fragment."
    status="enabled">
    <jcr:content
        jcr:primaryType="nt:unstructured"
        sling:resourceType="dam/cfm/models/console/components/data/entry/v2">
        <items jcr:primaryType="nt:unstructured">
                <field_title
                    jcr:primaryType="nt:unstructured"
                    sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
                    fieldLabel="Title"
                    name="title"
                    metaType="text-single"
                    valueType="string"
                    required="{Boolean}true"
                    listOrder="100"/>
                <field_subtitle
                    jcr:primaryType="nt:unstructured"
                    sling:resourceType="granite/ui/components/coral/foundation/form/textfield"
                    fieldLabel="Subtitle"
                    name="subtitle"
                    metaType="text-single"
                    valueType="string"
                    required="{Boolean}false"
                    listOrder="200"/>
                <field_body
                    jcr:primaryType="nt:unstructured"
                    sling:resourceType="dam/cfm/models/editor/components/multitext"
                    fieldLabel="Body"
                    name="body"
                    metaType="text-rich"
                    valueType="string"
                    required="{Boolean}true"
                    listOrder="300"/>
                <field_author
                    jcr:primaryType="nt:unstructured"
                    sling:resourceType="dam/cfm/models/editor/components/fragmentreference"
                    fieldLabel="Author"
                    name="author"
                    metaType="fragment-reference"
                    valueType="string"
                    required="{Boolean}false"
                    listOrder="400"
                    modelPath="/conf/&lt;project&gt;/settings/dam/cfm/models/author"/>
                <field_heroImage
                    jcr:primaryType="nt:unstructured"
                    sling:resourceType="dam/cfm/models/editor/components/contentreference"
                    fieldLabel="Hero Image"
                    name="heroImage"
                    metaType="content-reference"
                    valueType="string"
                    required="{Boolean}false"
                    listOrder="500"/>
                <field_tags
                    jcr:primaryType="nt:unstructured"
                    sling:resourceType="cq/gui/components/coral/common/form/tagfield"
                    fieldLabel="Tags"
                    name="tags"
                    metaType="tag"
                    valueType="string"
                    required="{Boolean}false"
                    listOrder="600"/>
                <field_publishDate
                    jcr:primaryType="nt:unstructured"
                    sling:resourceType="granite/ui/components/coral/foundation/form/datepicker"
                    fieldLabel="Publish Date"
                    name="publishDate"
                    metaType="calendar"
                    valueType="calendar"
                    required="{Boolean}false"
                    listOrder="700"/>
                <field_readTimeMinutes
                    jcr:primaryType="nt:unstructured"
                    sling:resourceType="granite/ui/components/coral/foundation/form/numberfield"
                    fieldLabel="Read Time (min)"
                    name="readTimeMinutes"
                    metaType="number"
                    valueType="long"
                    required="{Boolean}false"
                    listOrder="800"/>
        </items>
    </jcr:content>
</jcr:root>

Place the Model XML at /conf/<project>/settings/dam/cfm/models/article/.content.xml (or recreate it in the AEM Models UI). The .zip bundles the XML, GraphQL, TypeScript types, a sample fragment, the JSON spec, and docs. Runs entirely in your browser.

AEM Content Fragment Model Generator — User Guide

This tool turns a simple field form into an AEM Content Fragment Model plus everything you need around it: a model .content.xml, a rich GraphQL query set, TypeScript types, a sample fragment, a JSON spec, and authoring docs — downloadable together as a .zip. It's a companion to the AEM Component Generator. Everything runs in your browser.

Quick start

  1. Pick a preset (Article, Author, Product, Event, FAQ, Page SEO Metadata) — or start from scratch.
  2. Set the model title, machine name, and description.
  3. Add fields — each with a property name, label, and data type. Reorder with the up/down arrows.
  4. Switch the output tab between Model XML, GraphQL, TypeScript, Sample, JSON, and Docs, then Copy, Download, or grab the whole bundle as .zip.

Presets, validation & import

  • Presets load a complete, realistic model you can tweak.
  • Validation flags duplicate, empty, reserved, or invalid field names; Fix names auto-converts everything to valid, unique camelCase.
  • Import JSON loads a previously generated JSON spec back into the form so you can continue editing or share a model.

Field options (Advanced)

Beyond name/label/type/required/multiple, expand Advanced on a field to set:

  • Help text, placeholder, and a default value
  • A dialog tab to group fields in the authoring UI
  • Min/Max for numbers and a validation regex for text
  • For fragment references: the model path and the referenced GraphQL type (so the GraphQL and TypeScript outputs expand it properly)

Field data types

Each type maps to an AEM CFM data type and a GraphQL type:

  • Single line text, Multi line text, Rich text → String
  • Number → Int
  • Boolean → Boolean
  • Date and time → Calendar
  • Enumeration (dropdown) → String (provide comma-separated options)
  • Tags → [String]
  • Content reference (asset) → String
  • Fragment reference → a nested type (provide the referenced model path)
  • JSON object → String

Mark a field multiple to make it a list (valueType[]).

Outputs

  • Model XML — the .content.xml for /conf/<project>/settings/dam/cfm/models/<name>, including field metadata (help text, default, tab, min/max, validation). Place it at that path (or recreate the model in the AEM Models UI).
  • GraphQL — a list query, a filtered list query, a single-fragment by-path query (with a variation argument), and _metadata + _variations selections, plus a persisted-query snippet for production.
  • TypeScript — interfaces matching the GraphQL response (with a MultiformatString helper for rich/multi-line text and string-literal unions for enumerations) — ready for a headless/Next.js consumer.
  • Sample — an example authored fragment as JSON, for mocking and SPA development.
  • JSON — a compact, documented spec of the model and its fields — handy for sharing, version control, or re-importing.
  • Docs — Markdown authoring documentation: a field table plus step-by-step instructions to create the model and author a fragment.
  • .zip — all of the above bundled, with the Model XML already at the correct /conf/.../models/<name>/.content.xml path.

Creating the model in AEM

  1. Go to Tools → Assets → Content Fragment Models.
  2. Select your configuration folder and click Create.
  3. Name the model and add the fields with the matching data types.
  4. Enable the model so authors can use it.

Querying with GraphQL

Run the generated query against your project's GraphQL endpoint, or save it as a persisted query for production — persisted queries are cacheable through the Dispatcher and avoid exposing the full query surface.

Caveats

The internal .content.xml format varies across AEM versions; treat the generated XML as a strong starting point and verify against your environment. Many teams create models through the UI and use this tool mainly for the GraphQL, JSON spec, and docs.