· 5 min read
How to Flatten GeoJSON Into a CSV Table
Heshan Fernando
Co-founder & COO
You’ve got a GeoJSON file — maybe an export from mapping software, maybe a public dataset of locations — and you need the data in a spreadsheet or another tool that doesn’t understand GeoJSON’s nested structure at all. GeoJSON is great for representing geographic features programmatically, but its structure (geometry objects nested alongside a properties object, all wrapped in Features and FeatureCollections) doesn’t map directly onto the flat rows-and-columns structure a CSV or spreadsheet expects.
The conversion is conceptually simple — extract each feature’s properties and geometry into a flat row — but doing it by hand means parsing nested JSON structure manually, which gets tedious and error-prone past a handful of features.
What flattening GeoJSON to CSV actually involves
A GeoJSON FeatureCollection contains a list of Features, each with a geometry object (describing a point, line, or polygon shape with coordinate data) and a properties object (arbitrary key-value metadata about that feature — a name, a category, whatever the dataset includes). Flattening this into CSV means turning each Feature into one row, with the properties becoming their own columns and the geometry represented in a way a spreadsheet can actually use — commonly as separate latitude/longitude columns for point data, or a coordinate string for more complex shapes.
The trickiest part is handling geometry types beyond simple points — a polygon or line has multiple coordinate pairs, which doesn’t flatten into a single lat/lon column pair the same clean way a point does.
Why people get stuck here
- Nested JSON structure doesn’t map to flat rows. GeoJSON’s properties and geometry live in nested objects, which requires deliberate extraction logic to turn into flat CSV columns.
- Inconsistent properties across features. Not every feature in a FeatureCollection necessarily has the same set of properties, which means the resulting CSV needs to handle missing values in some rows’ columns.
- Complex geometry types. Points flatten cleanly into lat/lon columns, but lines and polygons have multiple coordinate pairs that don’t reduce to a single pair the same way.
- Manual parsing doesn’t scale. Extracting properties and geometry by hand from raw JSON works for a couple of features and becomes impractical for a dataset with hundreds or thousands.
What a good GeoJSON to CSV converter looks like
Extracts properties into their own columns
Each property key across the feature set should become its own CSV column, with missing values handled sensibly for features that don’t have every property.
Handles geometry sensibly
Point geometries should convert cleanly into latitude/longitude columns; more complex geometries need a reasonable representation that a spreadsheet can still work with, even if it’s a coordinate string rather than separate columns.
Works directly from a Feature or FeatureCollection
Since GeoJSON files can be either a single Feature or a FeatureCollection wrapping many, the converter should handle both input shapes without requiring manual restructuring first.
Common mistakes to avoid
- Assuming every feature has the same properties, and not accounting for missing values in features that don’t.
- Losing precision on coordinate values during conversion, which matters for anything requiring accurate mapping afterward.
- Treating complex geometry types (lines, polygons) the same as simple points, when they need a different flattening approach.
- Manually parsing a large GeoJSON file by hand instead of using a proper converter, introducing transcription errors along the way.
- Forgetting to check the coordinate order — GeoJSON uses longitude, latitude order, which is the reverse of the more commonly expected latitude, longitude order, and mixing them up silently produces wrong locations.
How to do it with GeoJSON to CSV
Online Tool Store’s GeoJSON to CSV converts your data entirely in your browser.
- Open the GeoJSON to CSV tool.
- Paste or upload your GeoJSON Feature or FeatureCollection.
- Review the flattened CSV output, with properties and geometry as columns.
- Download the resulting CSV for use in a spreadsheet or other tool.
Because it runs locally, your geographic data doesn’t need to be uploaded to a third-party server for the conversion.
Frequently asked questions
Why does GeoJSON list coordinates as longitude, then latitude?
This follows the GeoJSON specification’s defined order, which is the reverse of how coordinates are often casually written (latitude, then longitude) — it’s a common source of confusion and a specific detail worth double-checking when converting or manually reading GeoJSON coordinate data.
How does the conversion handle a polygon or line, which have multiple coordinate points?
Since a single row in a CSV doesn’t naturally hold multiple coordinate pairs the way it can a single lat/lon pair, complex geometries typically get represented as a coordinate string or similar compact format in one column, rather than being split across separate lat/lon columns the way simple points are.
What happens if some features in my GeoJSON have different properties than others?
A good converter should still produce a coherent table by including all property keys found across the feature set as columns, leaving a blank or null value for any feature missing a particular property — rather than failing or silently dropping data.
Final thought
GeoJSON’s nested structure exists for good reasons in a GIS context, but a flat CSV is what most non-GIS tools actually need — converting deliberately, rather than manually reshaping JSON by hand, keeps the geographic data intact through the transition.