Preparing Content for Translation



Extension .json
Smartling Identifier json
Example File (see example below)
Resources Official JSON Standards 

JSON files are based on name/value pairs. For example, in this basic JSON file “button1” is the name and “Home” is the value.


"button1": "Home"

Name/value pairs can be nested so that a path of several names leads to a value.

Smartling parses JSON files for translatable strings, and for key/variant metadata (Smartling keys) and translator instructions relating to those strings. Only JSON values can become strings or translator instructions in Smartling. Depending on how your file is structured, however, you may want to capture either a JSON value, or part of a name path as a key. Smartling allows for either option using the translate_paths directive.

Default Parsing

If you upload a JSON file without any custom Smartling Integration directives Smartling will:

  1. Capture all values in the file as strings.
  2. Use the complete name path to each string as key and variant data.
  3. Create placeholders in the strings using a default regular express to capture a number of common placeholder formats.
  4. No Smartling String Instructions are captured.
  5. Deliver translations, one file per language.

To parse the strings using ICU MessageFormat you must use the Smartling file directive string_format (either inline or via API). See ICU MessageFormat for more info. If ICU string formatting is used, then that takes precedence over HTML and any HTML directive will be ignored if your directives resolve in a value being parsed for both ICU and HTML. It is possible in a single file to have both HTML formatted strings and ICU formatted strings but they must be on different paths.

If a string contains HTML, Smartling automatically parses the strings in the file with basic HTML parsing, even without any HTML directive. Just note, this basic parsing will not break down the JSON value with HTML into smaller strings. It is ingested as one string. If this is not desirable and you want the value to be broken down into smaller strings in Smartling based on the HTML formatting, you can use the string_format_paths HTML feature. This will benefit both your translation resources and your translation memory leverage.

It is worth noting that in doing so, you lose any "keys", however, you still have "variants". In most cases, such as translation Jobs, this is acceptable, however, this is not acceptable if you are importing translations from a file, as keys are critical for alignment.

Example JSON value:

"terms": "<p>These are the terms you should be aware of them.</p><h1>First things first</h1><p>The first thing about the terms is that they apply to you.</p><h1>Second things second</h1><p>The second things about the terms is that they apply to us.</p>"


Regular Parsing

(1 string with key + variant)

HTML parsing

(5 strings with variant only - translations cannot be imported)

<p>These are the terms you should be aware of them.</p><h1>First things first</h1><p>The first thing about the terms is that they apply to you.</p><h1>Second things second</h1><p>The second things about the terms is that they apply to us.</p>
  1. These are the terms you should be aware of.
  2. First things first
  3. The first thing about the terms is that they apply to you.
  4. Second things second
  5. The second things about the terms is that they apply to us.


Default Placeholder Format

If you do not specify a custom placeholder format, even if you specify other directives, Smartling will convert the following subtext of a string into a placeholder for that string:

  • {x}
  • {{x}}
  • ${x}
  • %x%
  • %%x%%
  • ##x##
  • __x__

Custom Integration

If you want to control how Smartling will capture the content and metadata from your JSON file, or specify a custom placeholder format, you can use custom Smartling directives. The directives can be added "inline" to the file or they be configured as API parameters.

JSON inline directives must be the "first" or "top" object in the JSON
If you are integrating "inline" the the integration "smartling" must be the first object in the JSON.

The syntax for directives might change if you are using them as API parameters instead of inlining them.

Below is an example of a JSON document with custom directives integrated in the file:

json.json file example:

"smartling" : {
"translate_paths": [{
"path": "*/translation",
"key": "{*}/translation",
"placeholder_format_custom": ["\\^\\^.*?\\^\\^"],
"variants_enabled" : "true"
"Key1": {
"attribute": "4215050",
"translation": "Hello, ^^USER_NAME^^.",
"translation-note": "^^username^^ will be the first name, e.g. Mary"
"Key2": {
"attribute": "400913",
"translation": "Home",
"translation-note": "Used in navigation to provide link back to home page."
"Key3": {
"attribute": "4215049",
"translation": "Copyright 2017",
"translation-note": ""
"Key4": {
"attribute": "4213290",
"translation": "About Us"

The value of placeholder_format_custom is a regular expression (regex). We want to match on a "^" character as part of our expression. "^" is a reserved character for regex so we must escape it with "\". Because we are saving this in a JSON file where "\" is itself a reserved character for escaping, we must escape it for the JSON file with an additional "\".

Uploading this file will result in the following strings and metadata:

String Key Instruction
Hello, ^^USER_NAME^^. Key1 ^^username^^ will be the first name, e.g. Mary
Home Key2 Used in navigation to provide link back to home page.
Copyright 2017 Key3  
About Us Key4  


The values of the "attribute" names are completely ignored.

One of the strings has an empty/null instruction and another has no instruction at all. No errors are registered because of this.


By default, the full path of keys leading to a string are captured as Key and Variant metadata. Custom key paths can be set and variant behavior turned off with directives

Specifying Paths

Some directives require you to specify a path or set of paths to keys or strings in the file. A path is a slash-separated string which uses Xpath-like syntax (although it’s not Xpath.). The nodes separator is always / (slash).

Wildcards are allowed in path definitions.

  • If no wildcards, then the path identifies a single node and all its children (“exact subpath”).
  • If wildcards, then a path identifies a set of nodes and all their children (“path pattern”). Currently, only the * (asterisk) wildcard is implemented, which means “one or more nodes with any names”.
  • Exact subpaths have precedence over path patterns.

For example, in the following path specifications:

[*/text, */string, system/log/text, system/log/text/details]

Smartling processes these paths as follows:

  • /description/text — matches */text.
  • /description/general/text - matches */text directly.
  • /description/text/general — matches its parent, /description/text , matches */text.
  • /system/log/text — matches both /system/log/text (exact path) and */text (pattern). Exact path takes precedence.
  • /system/log/text/details — matches its parent, /system/log/text and system/log/text/details (exact). Exact path takes precedence.

See Placeholders in Resource Files for more on placeholders.

Return Untranslated Strings as Empty

When using the API file/get to download JSON files from Smartling, the parameter includeOriginalStrings=false ensures that if no translations are available, Smartling returns an empty string. If the parameter is set to true, Smartling returns the original string.

Pseudo Translations

The pseudo_inflation directive is not supported as an inline directive for JSON files, however, you can still control pseudo inflation for JSON files by including it as an argument in the API upload request. For example: smartling.pseudo_inflation=70 will result in pseudo translation length being increased by 70 percent.




"smartling" : {
"directive_name" : "value",
"directive_name" : "value",


Values integer or NONE
Description Sets or removes the maximum characters allowed for a translation. If NONE is specified, character limits will be removed. (You can also remove the limit key/value pair and re-upload a file.)
Examples (See example below.)

   "smartling" : {
     "translate_paths" : [
       "character_limit" : "/*/limit"
       "character_limit" : "/*/charlimit"
   "testkey1" : {
     "limit" : 10,
     "text" : "item1",
     "id" : 1
   "testkey2" : {
     "limit" : 20,
     "text" : "item2",
     "id" : 2
   "testkey3" : {
     "limit" : 30,
     "text" : "item3",
     "id" : 3
   "testkey4" : {
     "charimit" : 100,
     "value" : "item4",
     "key : "key"


Control whether or not certain characters will be HTML escaped when delivering the translations.

Values  auto (default)
true (or yes)
false (or no) 
Description Can control whether or not characters will be "escaped" into entities when delivering translations. This can be set universally for the whole file via API, or by setting the directive at the top/start of the file. The directive can also be placed inline to control the behavior of specific strings.
In Auto mode Smartling escaping will depend on whether Smartling believes the specific string requires HTML escaping. With true or false this will force the behavior for all strings. 

To use inline:

"smartling":{"entity_escaping": "false"}

For example, your translation in the dashboard might look like this:
Smartling <hr> HTML escaping <, >, &, " example

By default, using the auto setting, we would assume this is HTML from the <hr> tag present in the translation and it would be delivered as:

Smartling <hr> HTML escaping &lt;, &gt;, &amp;, &quot;, example

When downloading the translated file.

Using false would deliver:

Smartling <hr> HTML escaping <, >, &, ", example 

with no characters entity escaped.


Values The value of this directive is expressed as exclude_paths:[path].

Excludes the specified path as content that will be translated.  Content will not be parsed.  

Notice that exclude_path always must be a sub-path of path pointer in the same set of translate_paths item.

  "smartling" : {
    "translate_paths" : [
  "nodes" : [
        "text" : "item1",
        "comment" : "comment1"
        "text" : "item2",
        "comment" : "comment2"
        "text" : "item3",
        "comment" : "comment3"
  "messages" : [
        "message" : "message1",
        "note" : "note1"
        "message" : "message2",
        "note" : "note2"
        "message" : "message3",
        "note" : "note3"



Description  Used to specify a standard placeholder format 
"smartling":{"placeholder_format" : "IOS"}

Specifies iOS-style placeholders for the file.






1) Custom Perl compatible regular expression.
2) NONE - disables any current custom placeholders

Description   Specifies a custom placeholder format. Any text in your file matching the regular expression you provide will be captured as a placeholder.
"smartling" : {
"placeholder_format_custom" : ["\[.+?\]"]

When customizing placeholders with this directive inside the file, the value must be expressed as an array of strings (square brackets).





The translate_paths directive tells Smartling which parts of your JSON file are translatable strings, keys and instructions.

The value is an array of objects. Each object contains one path, that is at the minimum the path to the strings to extract. For each path you can also optionally specify how to assign the key and translator instructions for each string found on that path.

The object takes three parameters:

path - the name path leading to a translatable string (required)
instruction - the name path leading to a translator instruction
key - EITHER the name path leading to a value you want to capture as a Smartling key OR the part of a name path leading to a translatable string you want to use as a Smartling key

For path and instruction, see Specifying Paths.

If your key is a JSON value, see Specifying Paths. If you want to capture part of the name path to the translatable string, give the path to the translatable string, surrounding the part of the name path you want to capture as the key with curly braces {}.

"smartling": {
"translate_paths": [{
"path": "//text",
"key": "/{}/text",
"instruction": "/*/notes"

An upload will fail if Smartling cannot find at least one translatable string in your file but, otherwise, errors in your key and instruction paths will not cause an upload to fail. If your key and instruction paths do not match any content in your JSON file, no keys or instructions will be captured, but the upload will still proceed. Check your content in the Dashboard after uploading to be sure you have captured the correct information.

For more information, see Advanced JSON Configuration.


translate_paths (to be deprecated)

Values  A comma-separated list of paths to be captured as strings for translation. Note: for new files, use the new translate paths object. 
Description  When included in this list, all plain text within the specified path will be considered a translatable string. 


"translate_paths": ["*/translation"]

Smartling will tranlate content in any path ending in translation, such as string/translation nav/translation, etc.



source_key_paths (deprecated)


A comma separated list of paths to use create “keys” for strings on translate_paths.

The key will be a space separated string of all the keys leading to the source string. For example: “string”, “group1 string”.

For new files, use the new translate paths directive.


Used to define the schema for capturing a key for each source string. Keys are required:

If you want to import pre-existing translations from a file with the same structure
If you want to create variants of strings that would otherwise be duplicates (By default Smartling does not create duplicate strings.)
Creating or updating variants for previously uploaded strings cause new strings to be created that will not have translations. The SmartMatch feature can be configured to automatically apply the existing translations, or translators can use the 100% match from the Translation to manually apply the translation.

Specify the full path to the value, then indicate which part of the path should be used as the key using {} notation.

"source_key_paths" : "{*}"

Smartling will capture the full path of keys leading to each translatable string as Key metadata.

"source_key_paths" : "data/item/{string_name/*}"

Smartling will capture string_name [any subsequent keys] as the key’





true|TRUE|on|ON OR false|FALSE|off|OFF


When enabled, Smartling will make strings unique using variant metadata. Must be used in conjunction with the source_key_paths directive, which provides the information needed to generate variant metadata.

If you have previously uploaded a file with variants turned off, and reupload the file with variants on, Smartling will capture all content as new strings. You can configure Smartmatch to automatically match the existing translations.

"smartling": {"variants_enabled" : "TRUE"}



Value  icu

Parse the strings in this JSON file using ICU MessageFormat rules for placeholders, SelectFormat, PluralFormat.

"smartling":{"string_format" : "icu"}



Values The value of this directive is expressed as [format]:[paths].

Specifies the format of strings for the specified paths and can enable HTML inside another file format.

Currently supported formats are:

  • HTML - string value will be parsed as HTML
  • ICU - string value will be parsed as ICU MessageFormat
  • TXT - string value will be parsed as plain text with strings separated by new lines.
  • Markdown - string value will be parsed as Markdown.
  • @default - (note the leading at-sign) string value will be treated as simple text.

Separate multiple paths by commas. 

You may specify a single path for a format or a comma-separated list of paths enclosed in square brackets. The list may be empty.

"smartling": {"string_format_paths" : "html: *"}

Smartling parses values of all nodes as HTML.


"smartling": {"string_format_paths" : "html: */text"}

Smartling enables HTML in text nodes (and their subnodes), regardless of their parents.


"smartling": {"string_format_paths" : "html: [/text, string]"}

Smartling enables HTML in text and string nodes (and their subnodes), regardless of their parents.


"smartling": {"string_format_paths" : "html: /product/description"}

Smartling enables HTML in /product/description and subnodes.


"smartling": {"string_format_paths": "icu: [*]"}

Smartling parses all strings as ICU MessageFormat


"smartling": {"string_format_paths" : "html: */text, @default: /system/log/text"}

Smartling enables HTML in text nodes (and subnodes), but disables HTML in /system/log/text (and subnodes), as the exact match overrides the pattern match.


When to use multiple string_format_paths in a single document, recommended use case:

If your document has disparate kinds of strings that are used in different contexts, for example, if your single JSON file contains application UI strings, with standard string formatting and placeholders, together with one or few keys that are just giant HTML documents (example; TOS or Privacy Policy).
Just remember the side effects of HTML parsing, including losing keys, and precendence rules for other formats.

Was this article helpful?