I want to paste a JSON value into a Shopify metafield. Should I minify or pretty-print it, and how do I check it is valid before saving?
Minified and pretty-printed JSON hold exactly the same data, so choosing between them is about readability and size, not validity. What matters is that the text is valid JSON. Paste it into the JSON formatter first: if it is valid you see its top-level type and stats, otherwise the exact line and column of the problem, and then you copy whichever form you want into the field.
The difference in numbers
The tool's built-in example is a small store-data value: store name, currency, two products and shipping details, 284 bytes as written across three lines. Minified it becomes 282 bytes on one line; formatted with 2 spaces it is 436 bytes over many lines. The data is identical in all three: an object with a depth of 4 and 16 keys.
So which do you paste? If the field is small and you will edit it by hand later, the formatted version is easier to read. If you care about size or are copying the value between systems, the minified version is lighter. Whether the platform has a length limit for the value or a preferred form is something to check in Shopify's current documentation for the field type you created; we do not assume it here.
Why check before saving
Because the value is usually typed by hand or adapted from an example, and small mistakes are easy: a comma after the last item, a missing quote. The platform might refuse to save with a generic message, or accept the value in a plain text field and then the theme that reads it fails. Checking in the tool gives you the error's line and column before any of that.
The steps
- Type or paste the value into the JSON formatter and validator.
- Wait for 'Valid JSON. Top-level type: object' or 'array', and make sure the type is what your theme expects.
- If an error appears, press 'Go to the error position' and fix it.
- Read any warnings under the result: duplicate keys, or integers that are too long.
- Choose 'Minify' or 'Format' as you decided, and copy the output into the field.
The duplicate-key warning
This is a mistake that does not break validity, which is why it slips through. Take a value like this:
{"size":"M","color":"black","color":"navy"}
It is valid JSON, but the key color appears twice. Minified, the output is {"size":"M","color":"navy"}: only the last value survived and black was lost. The tool shows a warning naming the duplicate key, and if you meant two colours, make them an array, such as "colors": ["black", "navy"].
Arabic inside the value
No need to worry about Arabic text: the tool keeps it as real letters and never turns it into escapes such as \u0645. If a line mixing Arabic and numbers looks reordered in the text box, that is how the browser displays bidirectional text; the data is in the correct order when copied. And if your data started as a table, convert it to JSON first with the CSV and JSON converter, then check it here.
Common questions
Is the pretty-printed form any less valid than the minified one?
No. Spaces and line breaks outside strings do not change the data, so both are equally valid.
Do prices change when minified?
The value does not, but numbers are written in their shortest form, so 45.50 becomes 45.5. If the format matters, write the price as a string.
Is the value sent to Shopify or any server?
No. The tool runs in your browser, and you are the one who copies the output to the platform.
