Home → JSON Data Type Transformer
Fix type mismatches in JSON. Convert string numbers to integers, normalize boolean strings, and clean up null values — instantly, in your browser.
APIs and data pipelines frequently produce JSON with incorrect data types. A common example is a number arriving as a string — "age": "30" instead of "age": 30 — or a boolean serialized as "active": "true" instead of "active": true. This tool automatically detects and corrects those mismatches.
All processing happens entirely in your browser — no data is ever sent to a server. Free to use, no account required.
"123" → 123, "3.14" → 3.14"true" / "false" → true / false"null" → nulltrue → "true" for systems expecting string booleans"" or "null" to proper nullType mismatches commonly occur when JSON is generated from a CSV file, database query result, or system that doesn't preserve native types. For example, SQL exports often serialize everything as strings, and CSV files have no concept of data types at all — every value is a string by default.
Auto-converting strings that look like numbers (e.g. "id": "007") can be risky if leading zeros are meaningful. This tool previews all changes so you can review them before applying. You can also target specific fields rather than converting everything.
Yes. The transformer recursively walks all nested objects and arrays, applying transformations at every level of depth.
Yes — a simple recursive approach works well:
function coerceTypes(value) {
if (Array.isArray(value)) return value.map(coerceTypes);
if (value !== null && typeof value === 'object') {
return Object.fromEntries(
Object.entries(value).map(([k, v]) => [k, coerceTypes(v)])
);
}
if (typeof value === 'string') {
if (value === 'null') return null;
if (value === 'true') return true;
if (value === 'false') return false;
if (!isNaN(value) && value.trim() !== '') return Number(value);
}
return value;
}
Related tools: JSON Repair | JSON Validator | Schema Validator | Flatten JSON | CSV to JSON
JSON transformations reshape data from one structure to another — renaming keys, extracting nested values, pivoting arrays to objects, and changing data types. This is essential for ETL pipelines and API data mapping.
// 1. Rename keys
const renamed = data.map(({firstName: first_name, ...rest}) => ({first_name, ...rest}));
// 2. Flatten nested object
const flat = {name: user.name, city: user.address.city, zip: user.address.zip};
// 3. Pick specific fields
const pick = ({id, name, email}) => ({id, name, email});
const subset = users.map(pick);
// 4. Group array by key
const grouped = users.reduce((acc, user) => {
(acc[user.role] = acc[user.role] || []).push(user);
return acc;
}, {});
// 5. Pivot object to array
const arr = Object.entries(scoreMap).map(([name, score]) => ({name, score}));
# Rename keys
jq '[.[] | {id: .userId, full_name: .name}]' input.json
# Filter and transform
jq '[.users[] | select(.active) | {id, name}]' input.json
# Group by field
jq 'group_by(.department) | map({dept: .[0].department, count: length})' input.json
# Flatten nested
jq '[.[] | {name: .name, city: .address.city}]' input.json
| Use Case | Description |
|---|---|
| API data mapping | Transform external API format to internal schema |
| ETL pipelines | Extract, transform, load between systems |
| Frontend normalization | Normalize API responses for state management |
| CSV preparation | Flatten nested JSON for spreadsheet export |
| Schema migration | Update JSON structure when schema version changes |
Not all type conversions are safe in every context. This table helps you decide which conversions to apply for your specific data source.
| Data Source | Safe Conversions | Caution |
|---|---|---|
| CSV → JSON | String→Number, String→Boolean, String→Null | Check for leading-zero IDs (e.g. "007") |
| MySQL export | String→Number, "NULL"→Null | TINYINT(1) used for booleans — safe to convert |
| Legacy API | String→Boolean ("true"/"false") | Avoid auto-converting numeric strings (IDs) |
| Form submission | String→Number for numeric fields | Phone/zip fields — keep as strings |
| Excel/Google Sheets | String→Number, ""→Null | Date strings — keep as strings |