json. minify Synchronous
Parse JSON text and serialize it again without optional whitespace. Use it to remove formatting from JSON before storing or transferring it. String contents are preserved; only the serialized representation is rebuilt.
Luau
json.minify(text: string, options: JsonDecodeOptions?) -> stringParameters
| Parameter | Type | Description |
|---|---|---|
text | string | JSON document to compact. |
options | JsonDecodeOptions? | Optional boolean useNull flag or options table. Null preservation is enabled by default; maxDepth defaults to 256. |
Argument fields
Luau
JsonDecodeOptions = boolean | {useNull: boolean?, maxDepth: number?}| Field | Description |
|---|---|
useNull | Defaults to true, preserving JSON null as json.null. false converts null to nil, which can remove table entries. A boolean options argument is shorthand for this field. |
maxDepth | Maximum nesting depth. Defaults to 256; an integer is required and is clamped to 1–4096. |
Returns
stringCompact JSON text. Invalid input raises a parse error.
Example
Luau
local pretty = json.encodePretty({ colors = { "pink", "white" } })
print(json.minify(pretty)) -- {"colors":["pink","white"]}