# Convert stringified JSON values back to real types

Paste JSON where every value is quoted and get real types back: numbers, booleans and nulls. Protects ZIP codes, big integers and chosen keys.

## Run it

- **CLI:** `gizza tool json-coerce-types '{"age": "42", "active": "true", "note": "null", "zip": "02134"}'`
- **Web:** https://gizza.ai/tools/json-coerce-types/
- **Agents:** machine-readable descriptor (parameters JSON Schema) at https://gizza.ai/tools/json-coerce-types/tool.json

## Inputs

- `input` — JSON _(field)_
- `numbers` — Coerce numeric strings to numbers _(field)_
- `booleans` — Coerce "true" / "false" to booleans _(field)_
- `nulls` — Coerce "null" to null _(field)_
- `bool_synonyms` — Also treat yes/no/on/off as booleans _(field)_
- `null_tokens` — Extra tokens that mean null _(field)_
- `empty_strings` — Empty strings _(field)_
- `trim` — Trim whitespace before testing _(field)_
- `leading_zeros` — Zero-padded numbers (0005, 02134) _(field)_
- `thousands` — Accept thousands separators (1,234.5) _(field)_
- `skip_keys` — Keys to never touch _(field)_
- `only_keys` — Only these keys _(field)_
- `indent` — Indent (0 minifies) _(field)_
- `output` — Output _(field)_

## Output

- Retyped JSON (text)

## Query parameters

Open the tool pre-filled and auto-run via URL:

- `input` — JSON
- `numbers` — Coerce numeric strings to numbers
- `booleans` — Coerce "true" / "false" to booleans
- `nulls` — Coerce "null" to null
- `bool_synonyms` — Also treat yes/no/on/off as booleans
- `null_tokens` — Extra tokens that mean null
- `empty_strings` — Empty strings
- `trim` — Trim whitespace before testing
- `leading_zeros` — Zero-padded numbers (0005, 02134)
- `thousands` — Accept thousands separators (1,234.5)
- `skip_keys` — Keys to never touch
- `only_keys` — Only these keys
- `indent` — Indent (0 minifies)
- `output` — Output

Example: `https://gizza.ai/tools/json-coerce-types/?input=%7B%22age%22%3A%20%2242%22%2C%20%22active%22%3A%20%22true%22%2C%20%22note%22%3A%20%22null%22%2C%20%22zip%22%3A%20%2202134%22%7D&numbers=true&booleans=true&nulls=true&bool_synonyms=true&null_tokens=NA%2CN%2FA%2C-%2Cnone&empty_strings=keep&trim=true&leading_zeros=keep&thousands=true&skip_keys=zip%2Cphone%2Cid&only_keys=counts%2Cscores&indent=2&output=json`

---

## About this tool

`json-coerce-types` is for already-valid JSON where every scalar was imported as text. It walks objects and arrays recursively and changes safe string values into native JSON types: `"42"` becomes `42`, `"true"` becomes `true`, and `"null"` becomes `null`.

The defaults are deliberately conservative for production data cleaning. Numeric strings, booleans and `"null"` are enabled, but leading-zero values such as ZIP codes, account IDs and phone-like fields stay strings unless you choose "Coerce to numbers". Integers outside the 64-bit range also stay strings instead of being rounded through floating point.

Use `skip_keys` when certain field names must never be touched, or `only_keys` when you want to retype one branch such as `counts` or `scores` and leave the rest of the document exactly as strings. Switch the output to "Change report" to audit every path that would change before copying the retyped JSON.

### Limits and edge cases

- Input must be valid JSON first. If the document has comments, trailing commas or unquoted keys, repair it before using this tool.
- The input cap is 5 MB.
- Object keys are never renamed or retyped; only string values can change.
- JSON has no date or BigInt type. Date-looking strings stay strings, and huge integers that would lose precision stay strings.
- Thousands separators are only accepted when the grouping is well-formed, such as `"1,234"` or `"1,234.5"`.

## FAQ

<details>
<summary>Will this change ZIP codes, phone numbers or IDs?</summary>

Not by default when they contain redundant leading zeros. Values such as `"02134"`, `"007"` and `"0005"` stay strings while `leading_zeros` is set to `keep`. For extra safety, add field names such as `zip`, `phone` or `id` to `skip_keys` so their whole subtree is copied through untouched.

</details>

<details>
<summary>Does this fix broken JSON?</summary>

No. This tool starts after parsing succeeds and only retypes string values inside a valid JSON document. If your input has comments, trailing commas, unquoted object keys or missing quotes, run a JSON repair or formatter first and then coerce the repaired document.

</details>

<details>
<summary>How do I see what changed before using the result?</summary>

Set `output` to `report`. The result becomes a plain-text audit such as `$.age: "42" -> 42`, including nested array paths like `$.items[0].active`. Switch back to `json` when the report looks safe.

</details>

<details>
<summary>Why did a number-looking string stay a string?</summary>

The parser only accepts strict JSON number shapes unless you enable the relevant option. `"1,234"` needs `thousands`, zero-padded strings need `leading_zeros = coerce`, and values such as `"12px"`, `"0x1f"`, `".5"`, `"1."`, `"NaN"` and `"Infinity"` are intentionally left alone.

</details>

## Related tools

- [Cluster Similar Values](https://gizza.ai/tools/cluster-similar-values/): Group near-duplicate values in a column (typos, casing, spacing) and get a canonical form per cluster. Runs in your browser, nothing is uploaded, free.
- [Identify a data sample's format, delimiter and columns](https://gizza.ai/tools/data-format-sniffer/): Paste a data sample and find out what it is: CSV, TSV, JSON, JSON Lines, XML, HTML, fixed-width or binary, plus delimiter, quote char, encoding and column types.
- [DynamoDB JSON Converter](https://gizza.ai/tools/dynamodb-json-converter/): Convert between DynamoDB typed AttributeValue JSON and plain JSON in both directions, with auto-detect and pretty or compact output.
- [Elasticsearch Bulk Formatter](https://gizza.ai/tools/elasticsearch-bulk-formatter/): Build a compact Elasticsearch _bulk API body from a JSON array. Choose index/create/update/delete, _index, _id field, and doc_as_upsert locally.
- [Fuzzy Name Matcher](https://gizza.ai/tools/fuzzy-name-matcher/): Match and deduplicate person or organization names with Jaro-Winkler, Levenshtein and Soundex. Paste names, tune the threshold, export groups, pairs, CSV or JSON.
