---
title: "Transformers"
slug: "transformers"
abstract: "How to use transformers to access document properties and values."
---
# Transformers

In Sitecore Search, you can use transformers to index structured documents like CSV, XML, and JSON. Used with [feed crawlers](https://doc.sitecore.com/search/en/users/search-user-guide/index-items/configure-indexing/configure-a-feed-crawler.html "Configure a feed crawler"), [API crawlers](https://doc.sitecore.com/search/en/users/search-user-guide/index-items/configure-indexing/configure-an-api-crawler.html "Configure an API crawler"), and [advanced web crawlers](https://doc.sitecore.com/search/en/users/search-user-guide/index-items/configure-indexing/configure-an-advanced-web-crawler.html "Configure an advanced web crawler") transformers can access a specific document property or object property, manipulate its value, then set that as the value of an entity's attribute.

The data in CSV, XML, and JSON, is typically lists of objects. In Search, you can use transformers to access contained properties and values as follows:

- [Document transformers](https://doc.sitecore.com/search/en/users/search-user-guide/index-items/additional-configurations-and-settings/transformers/create-document-and-attribute-transformers.html "Create document and attribute transformers") can access properties at the document level. They can also manipulate their values. For example, you can use JavaScript to transform a top-level node to an indexable object. Document transformers are displayed in a flat list.
- [Attribute transformers](https://doc.sitecore.com/search/en/users/search-user-guide/index-items/additional-configurations-and-settings/transformers/create-document-and-attribute-transformers.html#UUID-c389e7cf-a576-5566-2e76-de3cfc9212f1_section-idm1743454764193594 "Add an attribute transformer") can access the same property of every object in a list. They can also manipulate their values before indexing each object as an entity. For example, when indexing `movies.json`, the transformer can format every movie's `release_date` property to the format required by your entity's attribute. Attribute transformers are displayed in a group under an attribute name.

> [!important]
> Document transformers run first in the order they are listed, followed by attribute transformer groups, where the nested transformers run in the order listed.

The following examples describe use cases for document and attribute transformers.

## No transformers required

For crawlers indexing objects or rows in a CSV as index items, you do not need transformers when:

- The column name or field name matches an attribute of the entity.
- The column values are in the format as required to populate the attribute.

## Transform products listed in an HTML page to index them

To transform products listed in a HTML page to index them:

1. Create a *JavaScript* document transformer.
2. In the JS Source text area add the JS code to extract products as a JSON array of objects.
3. Add attribute transformers, where required, to index a product.

## Format title

To set the value for the *title* attribute in *Snake* format from the *title* column in a CSV:

- For the attribute *title*, create a column transformation to *Change case* to *Snake*.

    The transformer assumes that the CSV has a *title* column.

## Column and attribute do not have the same name

To set the value for the *available stock* attribute from the *units in stock* column in a CSV:

- For the attribute *available stock*, create an attribute transformation to *Copy from* the *units in stock* column.

## Set flag for limited stock

To set values for the *limited stock* attribute using the *units in stock* column in a CSV:

1. For the attribute *limited stock*, create an attribute transformation to *Copy from* the *units in stock* column.
2. For the attribute *limited stock*, create an attribute transformation by setting *True/False* to *True* when the value in the *limited stock* column is *Less Than* 100.