{"title":"Format - Liquid Tag Reference","slug":"format-tag-reference","url":"https://support.storeconnect.com/articles/format-tag-reference","url_markdown":"https://support.storeconnect.com/articles/format-tag-reference.md","subtitle":null,"summary":"Reference for the `format` block tag, which sets how output values inside it are escaped or encoded: HTML, JavaScript, JSON, CSV, or raw. Use it to override the encoding for one region of a feed or template.","type":"Developer_Documentation","video_url":"","keywords":"liquid, tags, format, block tag, escaping, encoding, html escape, javascript escape, json, csv, raw output, feeds, storeconnect","last_modified":"2026-11-25T21:29:11+0000","body_markdown":"The `format` tag declares the output format of the content it wraps, which sets how each `{{ }}` value inside it is escaped or encoded. Outside any `format` block, values are HTML-escaped.\n\nA [feed](set-up-a-feed) already encodes values for the format it serves, so a feed template does not need this tag for that format. Use it to override one region, such as a script body, or a fragment you have already built yourself.\n\n## Syntax\n\n\n```liquid\n\n{% format '\u003cformat\u003e' %}\n  ...\n{% endformat %}\n\n{% format '\u003cformat\u003e', encode: false %}\n  ...\n{% endformat %}\n```\n\n\n| Property | Value |\n|----------|-------|\n| **Tag Name** | `format` |\n| **Type** | Block tag |\n| **Source** | Hydrofoil (core) |\n\nThe format can be a quoted string or a variable, such as the `format` variable a feed template receives.\n\n## Formats\n\n| Format | How `{{ }}` values are output |\n|--------|-------------------------------|\n| `html`, `xml` | HTML-escaped. This is also what happens with no `format` block. |\n| `js` | JavaScript-escaped, so a value cannot break out of a script string |\n| `json`, `jsonl` | JSON-encoded: strings quoted and escaped, numbers and booleans bare, `nil` as `null`, a list as a JSON array |\n| `csv` | Escaped as a CSV cell: quoted only when the value contains a comma, double quote, or line break. `nil` is an empty cell. |\n| `txt`, `md` | Raw, with no escaping |\n\nUse the short format names in this table, not MIME types. An unrecognized format is HTML-escaped.\n\nWith `encode: false`, values inside the block are output raw, whatever the format.\n\nA nested `format` block uses the format it declares. The outer format resumes after the inner block closes and does not re-encode the inner output.\n\n## Examples\n\nEscape values for a script inside an HTML page:\n\n\n```liquid\n\n\u003cscript\u003e\n  {% format 'js' %}\n    var productName = \"{{ product.name }}\";\n  {% endformat %}\n\u003c/script\u003e\n```\n\n\nEmit a fragment you have already built as JSON, without encoding it again:\n\n\n```liquid\n\n{%- new Map extra -%}\n{%- assign extra = extra | set_key: \"source\", \"storeconnect\" -%}\n{%- assign extra_json = extra | json -%}\n{% format 'txt', encode: false %}{{ extra_json }}{% endformat %}\n```\n\n\n## Security\n\nThe `format` tag works in every template, not only feeds. A raw block (`txt`, `md`, or `encode: false`) turns off HTML-escaping for every value inside it. Never wrap customer-entered data in a raw block on an HTML page, because that removes the protection against cross-site scripting."}