iPhone location journals

Convert KML or KMZ to CSV, and CSV to KML, in your browser

Drop a KML or KMZ to get a CSV for Excel or Google Sheets, or drop a CSV to get a KML. The file stays in your browser.

Drop a KML, KMZ or CSV file. It stays on this device.

Drop a KML or KMZ to get a CSV for Excel or Google Sheets, or drop a CSV to get a KML. The file stays in your browser. The type is detected from the file’s content, not its name. You see a report of what was read, written and skipped before you download anything. No account, no upload and no analytics. Files are read with your browser’s File API, and a KMZ is unzipped with the browser’s built-in DecompressionStream.

What’s in the CSV

Every row has the same fixed columns, in this order, followed by one column for each ExtendedData name found in the file. Each <Data name="…"> and each <SimpleData name="…"> becomes a column named after it. The header row is always written. The column names for latitude and longitude are spelled out, so the file does not depend on anyone remembering KML’s order.

ColumnWhat it holds
placemarkThe placemark’s number in the file, starting at 1. Rows with the same number belong together.
name, descriptionThe placemark’s name and description. Descriptions are turned into plain text unless you choose to keep the HTML.
folderThe names of the folders it sits in, joined with “ / ”.
geometryPoint, LineString, LinearRing, Polygon or gx:Track.
partThe number of the part inside a MultiGeometry or gx:MultiTrack. Empty for a placemark with one geometry.
vertex, vertex_countThe vertex’s number within its part, and how many vertices the part has.
latitude, longitudeDecimal degrees, WGS 84, written exactly as they appear in the file.
altitude_mThe third number of a KML coordinate, as written. Empty when there is none.
time_utcFrom TimeStamp/when, or from each when of a gx:Track, converted to UTC.
original_timeThe time exactly as written, when it is not already plain UTC (for example 2000-01-01T09:30:00-05:00), or when it could not be read, such as a date with no time of day.

Example: synthetic data

This is synthetic, invented data, from a made-up park. It is not anyone’s trip. synthetic-kml-to-csv.kml has seven placemarks. These are five of the 17 rows it produces in the default one-row-per-vertex mode, with some columns left out to fit. The full output is in synthetic-kml-to-csv.expected.csv.

placemarknamegeometryvertexlatitudelongitudealtitude_mtime_utccategory
1Made-up fountainPoint140.7829-73.9654152000-01-01T14:30:00Zlandmark
2Bench, "north" sidePoint140.7835-73.9660seating
4Made-up loop pathLineString140.7829-73.965415path
4Made-up loop pathLineString240.7832-73.965816path
4Made-up loop pathLineString340.7834-73.966317path

The fountain’s time in the file is 2000-01-01T09:30:00-05:00, so time_utc shows 14:30 UTC and original_time keeps the original text. The category column came from the placemarks’ ExtendedData. The sample’s third placemark has a name that starts with =, which is why cells get an apostrophe.

Why there are more rows than placemarks

A KML placemark can hold a whole line. A CSV row can hold only one position. So by default the tool writes one row per vertex: a LineString with 400 vertices becomes 400 rows that share a placemark number and count up in vertex. The report calls the extra rows “line vertices expanded”. A timed gx:Track is the same, with one time_utc per row. Google describes gx:Track in the KML reference as pairing each when with a gx:coord.

Choose one row per placemark if you want a list of places, not a list of points. Each geometry then gets one row with its first vertex and a vertex_count. The rest of the line is not in that CSV. Use it for counting and sorting, not for rebuilding a path.

The Google KML reference defines each of these elements.

KML is longitude first

In KML, a coordinate is written longitude,latitude[,altitude], with no spaces inside a tuple and a space between tuples. The Google KML reference states this order for coordinates. Most spreadsheets, and most people, say latitude first. Copying the numbers across unchanged is the commonest way to end up with points in the wrong place.

This tool does the swap for you and labels the result. A KML coordinate -73.9654,40.7829,15 becomes latitude 40.7829, longitude -73.9654 and altitude_m 15. Going the other way, a CSV row with latitude 40.7829 and longitude -73.9654 is written -73.9654,40.7829. The digits are copied as written, not rounded. Check the local plot in the report: a swapped pair would show up in a different place. A latitude outside −90 to 90, or a longitude outside −180 to 180, is rejected and counted, which also catches many swaps.

KMZ files: what’s inside, and what is skipped

A KMZ is a ZIP archive that holds a KML file and, often, the files it refers to, such as icons and overlay images. Google’s KMZ archives guide says the KML at the top level is normally named doc.kml. The tool reads doc.kml and, if there is none, the first .kml at the top level of the archive, the same way the KML and KMZ viewer does. It does this in your browser, with no library and no upload. Both stored and deflate-compressed entries work, and the file is recognised by its ZIP signature, so a KMZ renamed .zip or .kml still opens.

What is not converted is listed in the report, with counts and a reason:

Encrypted or ZIP64 archives, and files with a DOCTYPE or entity declaration, are refused with a message.

Open the CSV in Excel or Google Sheets

A CSV is plain text. Any spreadsheet program can read it, but each one decides how to split the columns and how to guess the type of each cell, so open it with an import step if you can, not by double-clicking.

  1. Look for the program’s import command rather than opening the file directly. Excel has Data → From Text/CSV, which Microsoft’s text and CSV import guide describes. Google Sheets has its own import command; check Google’s help for the current steps.
  2. Choose UTF-8 and a comma separator, and make sure the header becomes the column names.
  3. Keep time_utc as text at first if you want to see the exact value. Spreadsheets often reformat dates.
  4. Check the first rows against the report: latitude should be between −90 and 90.

We have not tested a particular version of any spreadsheet program, so these are general steps.

Why there is a UTF-8 BOM, and an apostrophe

Values that contain a comma, a double quote or a line break are put in double quotes, and a quote inside is doubled, as in RFC 4180. Lines end with CRLF.

Make a KML from a spreadsheet

Save the sheet as a CSV (in most spreadsheet programs, File → Save As or Download offers it), then drop it above. The file needs a header row and two columns of decimal degrees: latitude from −90 to 90 and longitude from −180 to 180. Degrees-minutes-seconds text such as 40°46′58″N is not converted; those rows are skipped and listed by row number.

FieldHeader names recognisedWritten to KML as
Latitude (required)lat, latitude, yThe second number of coordinates
Longitude (required)lon, lng, long, longitude, xThe first number of coordinates
Namename, title, label<name>
Altitudeele, elevation, elevation_m, alt, altitude, altitude_mThe third number of coordinates
Timetime, timestamp, time_utc, date, datetime<TimeStamp>, in UTC. A time with no zone is treated as UTC and counted in the report.
Descriptiondescription, desc, notes, comment<description>
Every other columnAny headerA <Data name="…"> in ExtendedData, when the cell is not empty

The output is KML 2.2, with coordinates in longitude,latitude[,altitude] order. Points writes one Placemark per row. One line writes a single LineString through the rows in file order. If you convert a CSV that this page wrote, the third option groups the rows back into the same placemarks, folders and parts. A placemark that was exported in one-row-per-placemark mode has only its first vertex in the CSV, so it comes back as a Point, and the report says so.

KMZ download. The page can also write a KMZ. It builds the ZIP itself with the stored method (no compression) and one entry, doc.kml, with no library. The KML download is the same content without the ZIP.

Open the result in Google Earth or My Maps

For Google Earth, check Google Earth Help for the current import steps. For My Maps, Google lists the supported file types in its import help; check it before you rely on a file type or size. The site’s guide to opening a GPX file in Google Maps shows the My Maps steps on a computer. We have not tested these apps with this tool’s output, so open a small file first.

Round trip

CSV written by this tool comes back as equivalent placemarks: the same names, the same coordinates in the same order, and the same ExtendedData values. The site’s tests check this with the synthetic sample. Styles are not in the CSV, so they are not in the result, and polygon holes are not kept. Folder names containing “ / ” come back as nested folders.

Limits

Related tools and guides

Questions

Is it free?

Yes. There is no account, no limit on how many files you convert and nothing to install.

Does it upload my file?

No. The file is read, converted and saved in your browser. The page blocks network connections and loads no analytics, so it cannot send the file anywhere. The web server sees an ordinary request for the page and its scripts, not your file or its name.

Can I convert a KMZ to CSV?

Yes. Drop the KMZ as it is. The tool unzips it in your browser and converts the doc.kml inside. Images in the archive are listed as skipped.

Can I convert to Excel (.xlsx)?

Not directly. The tool writes CSV, which Excel and other spreadsheet programs open, and has no .xlsx writer. Open the CSV in your spreadsheet program and save it as a workbook there if you need one.

Why does my KML have more rows than placemarks in the CSV?

Lines and tracks are written one row per vertex. See why there are more rows than placemarks, or choose one row per placemark.

Sources

Make your own KML or CSV of where you’ve been.

Whereday records visits and routes on your iPhone and exports KML, CSV, GPX, GeoJSON and more. Exporting to a file requires export access, and existing users keep the access they already have; see current pricing.

Download free for iPhone