CSV to KML converter
Turn a spreadsheet of places with latitude and longitude into a KML file for Google Earth: one placemark per row, every other column kept. Excel files work too. Free, and no account needed.
Convert CSV to KML online, in your browser
The Spatibase CSV to KML converter turns a CSV, TSV or Excel (.xlsx) file into KML in your web browser. What happens to your rows:
- Each row becomes a placemark. Its position comes from the latitude and longitude columns, found by their names (
lat,lng,lon,x,yand more). - Labels and balloons are filled. A
name,titleorlabelcolumn becomes the placemark’s<name>, adescriptioncolumn its balloon text, and every other columnExtendedData. - Rows without coordinates are listed. By row number in the notes, never dropped silently.
- Never uploaded. Files up to 50 MB and 50,000 rows, no account.
How to convert CSV to KML
- Check the sheet: a header row, a latitude and a longitude column in decimal degrees, and ideally a
namecolumn for the labels. - Save it as CSV or .xlsx and drop it on the box above, or press Choose a file. The sample is five Barcelona places with
name,latitudeandlongitude. - Look at the map. The notes say which columns gave the coordinates and list any rows that were left out.
- Press Download KML.
- Open the file in Google Earth Pro with File → Open, or add it to Google My Maps with Add layer → Import. In Google Earth on the web, create a project and import the KML from your computer.
How your columns end up in the KML
| What | What happens |
|---|---|
| Each row with coordinates | A <Placemark> with a <Point>, in the order of the sheet. |
| Latitude and longitude columns | The point’s <coordinates>, written longitude first (2.183801,41.385831) as KML requires. They don’t repeat as fields. |
Title column (name, title, label…) | The placemark’s <name>, the label Google Earth shows next to the pin. |
description column | The placemark’s <description>: the text in the balloon when you click it. |
| Every other column | ExtendedData, one <Data> per column, which Google Earth lists in the balloon. An empty cell is left out for that row. |
| Yes/no columns | Written as true and false when the column holds nothing else. |
Decimal commas (41,3851, 3,5) | Read as numbers, so a price of 3,5 is written as 3.5. A column that mixes numbers and text, or holds codes with leading zeros such as 08001, keeps its text as it is. |
| Rows without usable coordinates | Left out, with their row numbers in the notes under the map. |
| An elevation or height column | Stays a field. The placemark sits on the ground. |
| Colours, icons, folders | None: Google Earth shows its default pin for every row, in one list. |
Getting a spreadsheet ready for Google Earth
The converter needs three things from your sheet:
- A header row. Column names in the first row; every row below it is one place.
- Coordinates in decimal degrees. Latitude between -90 and 90 and longitude between -180 and 180, such as
41.385831and2.183801. Degrees and minutes (41°23′09″N) and UTM metres aren’t read. - A column for the label. Call it
nameand Google Earth shows it next to each pin. Without one, every placemark is unnamed.
Points only. One row is one position, so the KML holds placemarks, not lines or areas. A wkt column with a shape in it stays text. For lines and areas, start from GeoJSON or a shapefile.
Two cases where a different step comes first:
- Only addresses? KML needs coordinates, and this page doesn’t look addresses up, because that would send your data to a geocoding service. Spatibase looks up to 250 addresses per import when you bring the CSV into a project.
- Going to Google My Maps? It reads CSV itself and asks for the position and title columns. The KML is for Google Earth, GIS apps and anything that wants one file with names and fields together.
CSV to KML on the command line with GDAL
GDAL’s ogr2ogr builds points from two columns once you tell it their names:
# KEEP_GEOM_COLUMNS=NO: the coordinate columns don't repeat as placemark data
ogr2ogr -f KML places.kml places.csv \
-oo X_POSSIBLE_NAMES=longitude -oo Y_POSSIBLE_NAMES=latitude -oo KEEP_GEOM_COLUMNS=NO
# the label column is called title: say so, or the placemarks get no name
ogr2ogr -f KML places.kml places.csv \
-oo X_POSSIBLE_NAMES=lon -oo Y_POSSIBLE_NAMES=lat -oo KEEP_GEOM_COLUMNS=NO -dsco NameField=titleHow GDAL’s KML differs: the placemarks sit in a folder named after the file, and the columns are written as typed SchemaData with a <Schema> at the top. Only a column called Name (in any case) becomes the label unless you set NameField.
GPSBabel works for simple sheets: gpsbabel -i unicsv -f places.csv -o kml -F places.kml reads name, latitude and longitude, but drops the columns it doesn’t know.
Questions about converting CSV to KML
What should the latitude and longitude columns be called?
Any of the common names works, in any case: latitude, lat or y, and longitude, lng, lon, long or x, plus a few other languages (breite and laenge, latitud and longitud). The notes under the map say which two columns were used. The values must be decimal degrees.
Does Google Earth import CSV files by itself?
Google Earth Pro on the desktop does: choose File → Open, pick the .csv, and a wizard asks which fields hold latitude and longitude. A KML is easier to pass on, because the names and fields travel with it and it opens the same way in Google Earth, My Maps and GIS apps.
Why are some rows missing from the KML?
They have no usable latitude or longitude: an empty cell, text instead of a number, or a value out of range. The notes under the map list them by row number (the first ten). Fix them in the sheet and drop it again.
Why are my placemarks in the wrong part of the world?
Most often latitude and longitude are swapped, or the headers sit on the wrong columns. Barcelona swapped (latitude 2.18, longitude 41.38) is still a valid place, in East Africa, so it can’t be caught automatically. Check that the latitude column holds the values that match your area.
Can I convert an Excel file to KML?
Yes. Drop the .xlsx as it is: the first sheet with data is read, and the notes say which sheet. Old .xls files and Numbers or LibreOffice sheets need saving as .xlsx or CSV first.
Do the other columns show up in Google Earth?
Yes. They are written as ExtendedData, and Google Earth lists them when you click a placemark. Google My Maps reads them too and shows them as the place’s details.
Moving the places into Spatibase? Read how to import your data. Need another pair of formats? The GIS file converter converts between all of them.