# GeoJSON to CSV converter

> Flatten a GeoJSON FeatureCollection into a table: one row per feature, every property as a column, and the geometry as coordinates and WKT. Free, and no account needed.

Open the tool: https://spatibase.com/tools/geojson-to-csv/

**GeoJSON in, a flat table out.** The Spatibase GeoJSON to CSV converter turns the features of a GeoJSON file into CSV rows in your web browser. How the table is built:

- **Every property gets a column.** All keys from all features, after `name`, `description` and `folder`. A feature without a key leaves its cell empty.
- **The geometry in two forms.** `latitude` and `longitude` for single points, and a `wkt` column with the shape of every feature, lines and polygons included.
- **Nothing leaves the browser.** UTF-8 with a byte order mark for Excel, files up to 50 MB, no account.

## What it does
- Convert GeoJSON features to CSV rows
- One column for every property found in any feature
- Latitude and longitude columns for points
- A WKT column for points, lines, polygons and collections
- Nested objects and arrays kept as JSON text
- UTF-8 with a byte order mark, so Excel reads accents
- Runs in the browser: nothing is uploaded

## How to convert GeoJSON to CSV
1. Have the GeoJSON as a file: a `.geojson` or `.json` from QGIS, geojson.io, an API or a Spatibase export (Export entries (GeoJSON) in the project menu).
2. Drop it on the box above, or press Choose a file. The sample turns into 9 rows: 5 places, a walking route and 3 areas.
3. Look over the list under the map: each feature there is one row of the CSV.
4. Press Download CSV.
5. Open it in Excel or Google Sheets, or load it with `pandas.read_csv`. The `wkt` column goes straight into PostGIS or BigQuery.

## Formats and limits
- **Opens:** .geojson or .json, up to 50 MB. Other map files (KML, KMZ, GPX, GeoJSON, shapefile, CSV) convert too.
- **Downloads:** CSV, GeoJSON of the same features.
- **Privacy:** the file is read in your browser and never uploaded.
- Try it with a sample: https://spatibase.com/tools/geojson-to-csv/?sample=1
- Download the sample file (the one Open a sample opens): https://spatibase.com/tools/samples/barcelona.geojson

## How your GeoJSON is laid out in the CSV
| What | What happens |
|---|---|
| Features | One row each, in file order. A feature without geometry is left out, and the notes count it. |
| First three columns | `name`, `description` and `folder`, always present. They fill from properties with exactly those keys and stay empty otherwise. |
| Other properties | One column per key, in the order they first appear. A `Name` or `title` key gets its own column. |
| Numbers and `true`/`false` | Written as they are, such as `4.5` and `true`. The CSV itself has no types; Excel and pandas guess them again. |
| Nested objects and arrays | JSON text in one cell, such as `{"k":1}` or `["a","b"]`. |
| `null` values | Empty cells. |
| Point coordinates | `latitude` and `longitude` columns, latitude first, with the numbers exactly as the file stores them. |
| Every shape | The `wkt` column: `POINT`, `LINESTRING`, `POLYGON` with its holes, the `MULTI` types and `GEOMETRYCOLLECTION`. MultiPoints get WKT only, no latitude and longitude. |
| Altitude | Dropped from the WKT, which holds longitude and latitude only. |
| Properties named `latitude`, `longitude` or `wkt` | Replaced by the columns the converter computes from the geometry. |
| Feature `id` | Not written: the columns come from `properties` only. |

## Turning nested GeoJSON into a flat table
**GeoJSON is a tree; CSV is a grid.** Each feature carries its own set of `properties`, and one feature may have keys the others lack. A CSV needs the same columns on every row.

The converter flattens it in three moves:

- **Columns from the union of keys.** It collects every property key of every feature and gives each one a column. Where a feature lacks a key, its cell stays empty.
- **Structure as text.** A value that is itself an object or a list can’t spread over columns without guessing names, so it stays one JSON string you can parse later.
- **Geometry as WKT.** Well-Known Text writes any shape on one line, longitude before latitude. The walking route in the sample becomes a single `LINESTRING` cell with 405 coordinate pairs.

**A long cell for a detailed shape.** A country border can hold tens of thousands of coordinates, and Excel stops a cell at 32,767 characters. Read such files with pandas, a database or QGIS rather than a spreadsheet.

## Convert GeoJSON to CSV on the command line
For points, jq writes the rows in one line. For any shape, GDAL’s ogr2ogr adds a WKT column:

```bash
# points: name, latitude, longitude
jq -r '.features[] | [.properties.name, .geometry.coordinates[1], .geometry.coordinates[0]] | @csv' places.geojson > places.csv

# any shape: every property plus a WKT column
ogr2ogr -f CSV places.csv places.geojson -lco GEOMETRY=AS_WKT
```

**In Python,** geopandas does it in two lines: `gdf = gpd.read_file("places.geojson")`, then `gdf.assign(wkt=gdf.geometry.to_wkt()).drop(columns="geometry").to_csv("places.csv", index=False)`.

**Nested properties as columns?** `pandas.json_normalize` spreads objects into columns such as `address.city`, which this page leaves as one JSON cell on purpose.

## Frequently asked questions
### How do I open a GeoJSON file in Excel?
Excel has no GeoJSON import. Power Query can read the file as JSON, but you then expand the nested records and coordinate lists by hand. Convert it to CSV here and double-click it instead: each feature is a row with its properties, point coordinates and a WKT column for the shape.

### How do I get latitude and longitude out of a GeoJSON file?
For points, this converter writes them in two columns, latitude first, the way most people write coordinates. In the GeoJSON itself they are stored the other way round, longitude first. Lines and polygons have many coordinates, so their shape goes into the wkt column instead.

### Can I split nested GeoJSON properties into separate columns?
Not on this page: an object or a list is written as JSON text in one cell, so no data is lost and no column names are guessed. To spread them out, read the GeoJSON with pandas and use json_normalize, or use jq to pick the fields you want.

### How do I load the wkt column into PostGIS or BigQuery?
In PostGIS, import the CSV into a table and run ST_GeomFromText(wkt, 4326) to make a geometry column. In BigQuery, load it as a table and use ST_GEOGFROMTEXT(wkt). The coordinates are WGS 84 longitude and latitude, the SRID 4326 those functions expect.

### Can I turn the CSV back into GeoJSON?
For points, yes: the CSV to GeoJSON tool on this site reads the latitude and longitude columns. Lines and polygons have only WKT, which that tool doesn’t read, so use QGIS (Add Delimited Text Layer with WKT geometry) or ogr2ogr for them.

### Is my GeoJSON uploaded when I convert it to CSV?
No. The table is built in your browser from the file on your computer, and Spatibase never sees it. The only thing loaded from the internet is the background map.

## Next step
Turn the file into a live map your team can edit: **Save to Spatibase (free)** on the page saves it to a free Spatibase project (https://app.spatibase.com/signup), your places on a map you can edit and a live GeoJSON address for your site. Or download the GeoJSON and import it by hand (https://spatibase.com/docs/content/import/).
