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
- Pick a preset (Article, Author, Product, Event, FAQ, Page SEO Metadata) — or start from scratch.
- Set the model title, machine name, and description.
- Add fields — each with a property name, label, and data type. Reorder with the up/down arrows.
- 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.xmlfor/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
variationargument), and_metadata+_variationsselections, plus a persisted-query snippet for production. - TypeScript —
interfaces matching the GraphQL response (with aMultiformatStringhelper 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.xmlpath.
Creating the model in AEM
- Go to Tools → Assets → Content Fragment Models.
- Select your configuration folder and click Create.
- Name the model and add the fields with the matching data types.
- 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.