GPS Field Area Measure Logo
GPS Field Area Measure
Geospatial

KML and GeoJSON Files Explained in Simple Words

KML and GeoJSON Files Explained in Simple Words Quick answer: KML and GeoJSON files are two ways to save places on a map, like points, lines an...

G

GPS Field Area Measure Editorial

Field GIS Specialist · 11 min read

KML and GeoJSON files shown with map points, paths, polygons, and geographic data conversion

KML and GeoJSON Files Explained in Simple Words

Quick answer: KML and GeoJSON files are two ways to save places on a map, like points, lines and shapes. KML is best for Google Earth and for keeping colours and icons. GeoJSON is best for web maps and apps. You can change one into the other with a free converter.

Have you been sent a map file and had no idea how to open it? Or been asked for a GeoJSON when all you have is a KML? You are not alone. Most people meet KML and GeoJSON files when they share field maps, land boundaries or GPS points. This guide explains both in plain words. You will learn what they are, how they differ, how to open them and how to switch between them.

What is a map file?

A map file is a small file that stores places. It does not hold the map picture itself. It holds the things on the map, such as:

  • Points: a single spot, like a gate, a well or a shop.
  • Lines: a path, like a road, a fence or a trail.
  • Shapes: an area, like a field, a plot of land or a lake.

Each one is saved with its map position, and often a name and a short note. Any map app can then read the file and draw those things in the right place.

Now let's meet the first type of map file, KML.

What is a KML file?

KML stands for Keyhole Markup Language. It is best known as the file type used by Google Earth. If you have ever saved a place in Google Earth, you have likely made a KML file. It is an open standard, looked after by a group called the Open Geospatial Consortium, so many apps can read it.

A KML file can hold:

  • Points, lines and shapes
  • Names and notes for each one
  • Colours, line widths and icons, so your map looks the way you want
  • Pictures and other extras

KML files end in .kml. You may also see .kmz. That is just a KML file packed into a zip, so it is smaller and can carry pictures and icons with it.

What it looks like inside. Here is a KML file with one place, a well. The word Placemark is KML's name for one place.

<kml xmlns="http://www.opengis.net/kml/2.2">

  <Placemark>

    <name>My Well</name>

    <Point>

      <coordinates>10.5,20.3</coordinates>

    </Point>

  </Placemark>

</kml>

The two numbers are the position. You will see below why the order matters.

Good for: sharing a map that must look the same for everyone, and opening it in Google Earth. You can read more in Google's KML guide.

KML is one side of the story. Here is the other.

What is a GeoJSON file?

GeoJSON is a simpler file type for saving places. Its full name is Geographic JavaScript Object Notation, but nobody says that. It is the choice for most web maps and apps. It follows an official standard called RFC 7946, so different tools read it the same way.

A GeoJSON file holds:

  • Points, lines and shapes
  • Details for each one, such as a name, an owner or an area size
  • No built-in colours or icons, because it saves the data, not the look. Some tools add their own style fields, but these are not part of the standard, so other tools may ignore them.

GeoJSON files end in .geojson or .json. They are plain text, so a person can open one in a basic text editor and read it. They are also often smaller and easier to work with than KML.

What it looks like inside. Here is the same well as a GeoJSON file. The properties part holds the details, like the name.

{

  "type": "Feature",

  "properties": { "name": "My Well" },

  "geometry": {

    "type": "Point",

    "coordinates": [10.5, 20.3]

  }

}

Good for: websites, mobile apps and any job where you want to use the map data in other software.

With both in mind, let's put them side by side.

KML vs GeoJSON: the main differences

  • Full name: KML is Keyhole Markup Language. GeoJSON is Geographic JavaScript Object Notation.
  • File ends in: KML uses .kml or .kmz. GeoJSON uses .geojson or .json.
  • Best known for: KML is known for Google Earth. GeoJSON is known for web maps and apps.
  • Colours and icons: KML has them built in. GeoJSON does not.
  • Pictures and extras: KML can carry them. GeoJSON cannot.
  • Reading it: KML is longer and harder to read. GeoJSON is shorter and easier.
  • Best use: KML is for showing a map to people. GeoJSON is for using map data in software.

One rule they share: both files write a place as longitude first, then latitude. In the examples above, 10.5 is the longitude and 20.3 is the latitude. The official GeoJSON standard sets this order, and it also says to use decimal degrees on the same Earth model that GPS uses (called WGS 84). Many people expect latitude first. Mixing them up puts your shapes in the wrong place.

Knowing the difference, the next question is which one you should pick.

Which one should you use?

Ask yourself what you plan to do with the file.

Choose KML if you want to:

  • Open the map in Google Earth
  • Keep your colours, icons and pictures
  • Send a map that looks exactly the same for everyone

Choose GeoJSON if you want to:

  • Show the map on a website or in an app
  • Use the shapes and details in other software
  • Keep the file small and easy to read

Not sure? Keep both. Save your original file, then make a copy in the other type when you need it.

Once you have the right file, you need a way to open it. Here is how.

How to open a KML or GeoJSON file

You do not need to be an expert. Free options exist for both.

To open a KML or KMZ file:

  • Google Earth: open the app or the web version and import the file.
  • Google My Maps: create a new map and import the file.
  • QGIS: a free desktop program that opens almost any map file.

To open a GeoJSON file:

  • A plain text editor: you can read the file, but you will not see a map.
  • QGIS: shows the shapes on a map.
  • A free online GeoJSON viewer: upload the file and see it on a map right away.

No tool that opens your type? Convert it. A KML file can become a GeoJSON file, and the other way round. You will see how next.

If you need to switch types, that is easy.

How to change KML to GeoJSON for free

You do not need to install anything. You can convert KML to GeoJSON in your browser with our free tool.

  1. Open the converter. Go to our KML → GeoJSON tool.
  2. Add your KML file. Choose the file from your phone or computer.
  3. Check the result. Make sure your shapes and names look right.
  4. Download the GeoJSON file. Save it where you can find it.
  5. Test it. Open the new file in your map app to make sure it lands in the right place.

What to expect after you convert:

  • Your shapes stay, and your names and notes usually stay too. Open the result and check.
  • Colours, icons, folders, pictures and time settings may be lost, because GeoJSON does not store them in a standard way.
  • Your original KML file is not changed, so keep it safe.

Going the other way? Use our GeoJSON → KML tool. Working with a Shapefile? Try the Shapefile → GeoJSON tool. You can find all of them in our GIS File Converters.

Have your own measurements to share? After you draw a field or a path in our map workspace, you can save it as KML or GeoJSON.

KML and GeoJSON are not the only map files. Here are a few others you may meet.

Other map files you may meet

  • Shapefile: an older type used a lot by governments and surveyors. It is not one file but a group of files, so it is usually sent as a .zip.
  • GPX: a file of GPS tracks and waypoints, made by hiking apps, running apps and handheld GPS units.
  • CSV: a simple spreadsheet list of places, with one column for latitude and one for longitude.
  • DXF: a drawing file used in design and building work (CAD).

Our GIS File Converters cover KML, Shapefile, GPX, DXF and CSV, so you can move between them in one place.

Sometimes a file does not behave as you expect. Here are the usual reasons and fixes.

Common problems and easy fixes

  • Your shapes land in the wrong place, or in the sea. The latitude and longitude are probably swapped, or the numbers are in another style, like degrees, minutes and seconds. Use longitude first, in decimal degrees. Our guide on how to read GPS coordinates explains the styles.
  • A shape looks broken or will not fill in. A shape must close. Its last point must match its first point.
  • The file will not open. The download may be damaged or cut short, so download it again. Also check the ending. A .kmz file is a zip, so it looks like nonsense in a text editor.
  • Names or notes are missing after converting. They may be stored in a different spot in the file. Open the new file and check, and go back to your original if needed.
  • Your colours disappeared. This is normal when you go to GeoJSON. Keep the KML if the look matters.
  • The file is slow or too big. Split it into smaller files, or remove points you do not need.
  • You edited the file in a word processor and it broke. Word processors add hidden characters. Use a plain text editor instead.

Every file like this is made of points on a map, and each point is written with two numbers. Our next guide, how to read GPS coordinates, explains what those numbers mean.

Frequently asked questions

What is the difference between KML and GeoJSON?

KML is a file type made for Google Earth, and it can keep colours, icons and photos. GeoJSON is a simpler file type made for web maps and apps, and it holds the shapes and their details but not the look. Both store places as points, lines and shapes.

Can I open a KML file without Google Earth?

Yes. Many free map apps and online viewers can open KML files. You can also change the file to GeoJSON and open it in most web map tools.

Will I lose anything when I change KML to GeoJSON?

You keep the shapes, names and notes. You may lose colours, icons and other style settings, because GeoJSON does not store them in a standard way. Always keep a copy of your original file.

How do I convert KML to GeoJSON for free?

Open our free KML to GeoJSON converter in your browser. Add your KML file, check the result, and download the new GeoJSON file. You do not need to install anything.

Which comes first in a GeoJSON file, latitude or longitude?

Longitude comes first, then latitude. KML uses the same order. Mixing them up is the most common reason shapes land in the wrong place after a switch.

What is a KMZ file?

A KMZ file is a KML file packed into a zip. It is smaller and can carry pictures and icons with it. Google Earth can open it directly.

How do I open a GeoJSON file?

You can read it in any plain text editor. To see it on a map, open it in a free program such as QGIS or an online GeoJSON viewer, or convert it to KML and open it in Google Earth.

Conclusion

KML and GeoJSON files do the same basic job: they save places on a map. KML is best when the look matters and you use Google Earth. GeoJSON is best for web maps and apps. Remember that both write longitude first, and keep your original file safe before you convert. When you need to switch, a free converter does it in seconds. Open the KML → GeoJSON tool and try it with your own file today.

Read next: How to Read GPS Coordinates explains the numbers behind every point in your file.

Tags

#Kml#Geojson#Gis Tools#Map Files#Geospatial Data