Sitecore Glass.Mapper Model Generator
Generate strongly-typed Glass.Mapper C# models from Sitecore templates — interface and class with [SitecoreType] and [SitecoreField] attributes.
Template
Template Fields
TitleSingle-Line Text
BodyRich Text
Generated HeroBanner.cs
Strongly-typed Glass.Mapper model with [SitecoreType] and [SitecoreField] attributes.
Strongly-Typed Sitecore Models in One Click
Writing Glass.Mapper models is pure boilerplate: one property per template field, the right C# type per Sitecore field type, the right attribute with the exact field name, virtual on every class property. Multiply that by every template in a project and it's hours of typing. This generator takes the template definition and emits the interface and class ready to paste into your Helix module's Models folder.
Type Mapping Reference
Single/Multi-Line, Rich Text →
stringCheckbox →
boolInteger →
int · Number → decimalDate / Datetime →
DateTimeGeneral Link →
Glass.Mapper.Sc.Fields.LinkImage / File →
Image / FileDroplink / Droptree →
GuidMultilist / Treelist →
IEnumerable<Guid>How to Use This Generator
- Enter the template name and ID — copy the GUID from the template item in Sitecore.
- Set the namespace following your Helix module convention.
- Add the fields exactly as they are named in the template (spaces are fine).
- Copy or download the generated .cs file.
Frequently Asked Questions
- What is Glass.Mapper?
- Glass.Mapper is the most widely used ORM for Sitecore. It maps Sitecore items to strongly-typed C# classes or interfaces, so instead of item["Field Name"] string lookups you work with typed properties, IntelliSense, and compile-time checking.
- What does this generator output?
- A C# file containing an interface and/or class decorated with [SitecoreType(TemplateId = ...)] and [SitecoreField] attributes, plus standard Id, Name, and Url members mapped via [SitecoreId] and [SitecoreInfo]. Field names map exactly as entered, including spaces.
- How do Sitecore field types map to C# types?
- Text fields (Single-Line, Multi-Line, Rich Text) map to string; Checkbox to bool; Integer to int; Number to decimal; Date/Datetime to DateTime; General Link, Image, and File to the Glass.Mapper.Sc.Fields types (Link, Image, File); Droplink/Droptree to Guid; and list fields (Multilist, Treelist) to IEnumerable<Guid>.
- Why are class properties virtual?
- Glass.Mapper supports lazy loading by creating proxy subclasses of your model at runtime, which requires properties to be virtual. Interfaces don't have this concern, which is one reason many teams prefer interface models.
- Should I map to item Guids or nested models for list fields?
- This generator uses IEnumerable<Guid> as a safe default. If you want fully hydrated objects, change the property type to IEnumerable<IMyOtherModel> — Glass will map the referenced items to that type automatically when it can.