GeoJSON Formatter
Pretty-print your GeoJSON with a chosen indent, or minify it to a single line for embedding. 100% in-browser.
GeoJSON Formatter
Before you start
You need either a .geojson file or raw GeoJSON text copied to your clipboard. Since GeoJSON is just a specific flavor of JSON, this tool works with any valid JSON structure, but I’ve optimized the defaults and file-handling for spatial data.
Your input must be valid JSON. If you have a stray comma at the end of an array or a missing closing brace, the browser’s JSON.parse engine will throw an error and tell you exactly which line and column is broken. I recommend running your data through the GeoJSON Validator first if you aren't sure it's spec-compliant.
There is no hard file size limit because nothing is uploaded to a server—it all happens in your browser's memory. For files larger than 100 MB, you might notice a brief stutter while your CPU handles the stringification, but it’s generally much faster than waiting for a round-trip upload.
How to use it
- Paste your GeoJSON into the left pane, or drag-and-drop a
.geojsonfile directly onto the text area. - Set the Indent value (default is 2). Use 0 if you want to manually minify, though there is a dedicated button for that.
- Click Pretty-print to expand the structure with whitespace, or Minify to strip every unnecessary byte.
- Check the Status bar to see the final character count and confirm the parse was successful.
- Click Copy to grab the result, or Download .geojson to save the formatted file back to your machine.
Options explained
Indent level
This controls how many spaces are used for each nesting level. 2 is the industry standard for web config, while 4 is a bit more "old-school" and readable for deeply nested GeometryCollection structures. Setting this to 0 is functionally the same as minifying.
Pretty-print vs. Minify
Pretty-printing makes the code human-readable by adding newlines and spaces. Use this when you need to debug a properties object or manually edit coordinates. Minifying collapses everything into a single, giant line. This is essential for production environments, as it can reduce file size by 20–30% just by removing "invisible" characters.
Example
Input (Minified):
{"type":"Feature","geometry":{"type":"Point","coordinates":[12,34]},"properties":{"name":"Test"}}
Output (Pretty-printed, 2-space indent):
{
"type": "Feature",
"geometry": {
"type": "Point",
"coordinates": [
12,
34
]
},
"properties": {
"name": "Test"
}
}
Tips & common pitfalls
- Key order is usually preserved. Modern browsers maintain the order of keys in an object during
JSON.parse(), so your"type"field should stay at the top if it was already there. - Coordinates can get long. If your file is huge because of high-precision coordinates (like 15 decimal places), formatting alone won't save much space. Use the Simplify tool to truncate that precision.
- Watch out for BOMs. Some Windows editors add a "Byte Order Mark" to the start of files. My parser tries to strip these, but if you see a "Unexpected token" error at position 0, that's likely the culprit.
- Trailing commas are illegal. Standard JSON doesn't allow a comma after the last item in a list. If you're hand-editing
features, make sure the last one doesn't have a comma after its closing brace.
Troubleshooting
I get a "SyntaxError: Unexpected token" message.
This means your input isn't valid JSON. The error message usually includes a line and column number. Check for missing quotes around property names, unclosed brackets, or those pesky trailing commas.
The "Download" button isn't working for a huge file.
Very large files (200 MB+) can sometimes hit browser-specific limits for "Blob" URLs. If the download fails, try clicking "Minify" first to reduce the string size, then use "Copy" and paste it into a local text editor like VS Code or Sublime Text.
My properties looks different after formatting.
While I try to preserve order, some JavaScript engines might reorder keys if they are strictly numeric. If your workflow depends on a very specific key sequence, always double-check the output before deploying.
Related tools
See also: if you need to do something adjacent on this site, try GeoJSON to CSV to flatten a feature collection into a CSV table, GeoJSON to KML to convert GeoJSON to KML for Google Earth, or GeoJSON Validator to check GeoJSON against the spec.
Frequently asked questions
Does this tool support TopoJSON?
No, this is strictly for GeoJSON. While they look similar, TopoJSON uses a different topology-based structure. You'll need to convert TopoJSON to GeoJSON first if you want to use this formatter.
Does formatting change the actual coordinate values?
No. This tool only changes the whitespace (indentation and newlines). It does not truncate decimals or simplify geometries. For coordinate-level changes, use the Simplify tool.
Is my data sent to a server?
Never. I built this tool to run entirely in your browser. Your GeoJSON is processed locally via JavaScript, so your sensitive location data never leaves your computer. You can even use this page offline.
Why use this instead of a generic JSON formatter?
You can certainly use a generic one, but this tool handles .geojson file extensions directly and is part of a suite that lets you pass data seamlessly between the viewer, validator, and simplifier without re-uploading.
What is the maximum indent allowed?
I’ve capped the UI at 8 spaces. Anything more than that usually makes GeoJSON files impossible to read on a standard monitor anyway!