Raw Values: How Data Is Stored In Sitecore

Data in Sitecore is not always stored the same way it is displayed.

Sitecore uses SQL Server to store most of its content. While content authors will see formatted text and structured content in the Content Editor and Experience Editor, Sitecore stores all data in a raw form in its database tables. Some raw values match their display value - for example, content based on the Single-Line Text data type. Most data, however, is transformed into custom XML or a direct reference to other Sitecore items.

Viewing Raw Values

The best way to understand how Sitecore stores various data types is to enable "Raw Values" in the Content Editor. To do this, click on the View tab on the Content Editor ribbon. Enable the Raw Values checkbox. A warning message should appear on all items to remind users that they are seeing raw values in item fields.

Enabling raw values via the 'View' tab.

There is a lot to learn from studying the raw values of content in Sitecore. Here are a few before/after examples of formatted/raw values that demonstrate how Sitecore stores data.

Single-Line Text

Plain, unformatted text is pretty simple and is stored the same way it is displayed.

Formatted value of Single-Line Text type.

Formatted content.

Raw value for Single-Line Text type.

Raw value.

Multi-Line Text

Multi-Line content is similarly simple as Single-Line Text, but captures line breaks.

Formatted value of Multi-Line Text type.

Formatted content.

Raw value for Multi-Line Text type.

Raw value.

Checkbox

The checkbox interface is pretty simple for content authors to understand, and are stored internally as '1' or '0'.

Formatted value of Checkbox type.

Formatted content.

Raw value for Checkbox type.

Raw value.

Droplist

A droplist field lets a user pick a text value from a predefined list. The source of the list is other Sitecore items. The selected value is stored as raw text.

Formatted value of Droplist type.

Formatted content.

Raw value for Droplist type.

Raw value.

Droplink

A droplink field is similar to the droplist field in that a user picks a value from a predefined list. Instead of storing the raw text value of the selection, a droplink stores the ID of the selected item.

Formatted value of Droplink type.

Formatted content.

Raw value for Droplink type.

Raw value.

Date/Time

Dates and times are displayed with a convenient datepicker and dropdown interface, but are converted to ISO 8601 UTC in the database.

Formatted value of Image type.

Formatted content.

Raw value for Image type.

Raw value.

Multilist

Multilist fields allow a user to choose multiple selections using two multi-line select lists. The formatted, structured interface is convenient for content authors. The selected items are stored as a pipe-delimited list of item IDs.

Formatted value of Multilist type.

Formatted content.

Raw value for Multilist type.

Raw value.

Image

Sitecore's inner workings really start to show with the Image field. While a nice selection/upload interface is available for authors, the raw value is actually a snippet of XML that defines all the properties that Sitecore needs for the image.

Formatted value of Image type.

Formatted content.

Raw value for Image type.

Raw value.

The full XML of the above image:

	
<image mediaid="{BEC3D16C-119B-4126-A34F-798757A2B92C}" alt="Spark Logo" height="" width="" hspace="" vspace="" />
	

File

Files (PDFs, musics, videos, documents, etc.) are managed via the Media Library through a custom interface. When added to a content item, the raw value is stored as a snippet of XML.

Formatted value of File type.

Formatted content.

Raw value for File type.

Raw value.

The full XML of the above file:

	
<file mediaid="{094AED03-02E7-4868-80CB-19926661FB77}" src="-/media/094AED0302E7486880CB19926661FB77.ashx" />
	

Link (Internal)

Internal links point to an item in the Sitecore content tree. Content authors get a nice tree-list dropdown to select a target item. Internally, Sitecore stores a snippet of XML that includes the target item ID.

Formatted value of Link (Internal) type.

Formatted content.

Raw value for Link (Internal) type.

Raw value.

The full XML of the above file:

	
<link text="" anchor="" linktype="internal" class="" title="" target="" querystring="" id="{14A913E9-0BF7-4F23-A1D2-729D1B976CBF}" />
	

Link (External)

External links store the external URL in its XML, but is otherwise the same as an internal link.

Formatted value of Link (External) type.

Formatted content.

Raw value for Link (External) type.

Raw value.

The full XML of the above link:

	
<link text="Sitecore Spark" linktype="external" url="https://www.sitecorespark.com" anchor="" class="external-link" target="_blank" />
	

Database Values

The raw values that you see displayed in the Sitecore Content Editor are the exact same values that are stored in Sitecore's VersionedFields table. Below is a sample of that table for the sample item used in this article:

Item field values from the database.

Raw database values in SQL Server Management Studio.

Accessing Sitecore Raw Values Programmatically

As a developer, you should never access Sitecore content via its raw value. The Sitecore API provides helper methods and classes that model all data types as objects. Writing content to its raw value form - either in code or via SQL - can lead to inconsistencies that surface in unexpected ways. Always use the Sitecore API to access, update, and delete content.