Convert DXF to GeoJSON

This converter turns a DXF drawing from AutoCAD, BricsCAD or another CAD program into one GeoJSON file for web maps such as Leaflet, Mapbox, OpenLayers and geojson.io. You enter the coordinate system of the drawing as an EPSG code, and the coordinates are converted to longitude and latitude, as standard GeoJSON requires. Each feature keeps its CAD layer, entity type, text and color as properties. The DXF is read in your browser and not uploaded.

Did a file not convert correctly? E-mail [email protected], ideally with a small sample file, and it will be fixed.

Key facts

DXF to GeoJSON: why convert

A site plan, a utility network or a survey drawn in CAD often has to go on a web map, in a dashboard or in a script, and those speak GeoJSON, not DXF. This page reads the DXF with GDAL, the open-source library behind QGIS, converts the coordinates from the drawing's grid (a UTM zone, a national grid or a State Plane zone) to WGS84 longitude and latitude, and writes one GeoJSON FeatureCollection following RFC 7946. Lines and polylines become LineStrings, closed polylines, circles and hatches become Polygons, points and blocks become their parts, and TEXT and MTEXT become points with the text in a property. The CAD color and lineweight are also written as simplestyle properties, so geojson.io and GitHub draw the drawing in its CAD colors. The map preview shows where the drawing lands before you convert, and nothing is sent to a server.

How to convert DXF to GeoJSON

  1. Drop your .dxf file in the box, or click to choose it. A .dwg must be saved as DXF first.
  2. Enter the coordinate system of the drawing as an EPSG code, such as EPSG:25832 for UTM zone 32N, or click one of the suggestions, and check that the map shows the drawing in the right place.
  3. Keep or untick "Closed polylines and circles become polygons", click Convert to GeoJSON and load the file in your web map, geojson.io or QGIS.

What changes when you convert

The EPSG code decides where the drawing lands

A DXF stores coordinates as plain numbers without a coordinate system, while standard GeoJSON is always longitude and latitude, so the converter has to know the drawing's system. Values such as 556000, 6324000 are UTM metres (for example EPSG:25832 in Denmark or Germany); 6-digit values in Britain are usually the British National Grid (EPSG:27700). The suggestions under the field list systems in which the numbers make sense. With the wrong code the drawing lands in the wrong country or a few hundred metres off, which the map preview shows before you convert.

Drawings in local coordinates

Architect drawings are often drawn around 0,0 in millimetres or metres and are not tied to the ground at all. No EPSG code fits them, and the status line warns when the result lands near 0° longitude and 0° latitude off the coast of Africa. Such a drawing must be georeferenced first, for example with the Vector Bender plugin in QGIS, or moved onto survey coordinates in CAD.

Properties of each feature

Every feature gets Layer (the CAD layer), Entity (such as AcDbPolyline, AcDbCircle or AcDbMText), Color as #rrggbb with ByLayer and ByBlock resolved, LineWidth in millimetres, Linetype and the entity Handle. Texts also get Text, TextSize in drawing units and TextAngle in degrees counter-clockwise. To style by layer in Leaflet or Mapbox, use the Layer property; to filter in QGIS, use it in an expression.

Curves become straight segments

GeoJSON has no arcs, circles or splines, so they become many short straight segments. Blocks such as trees, manholes and north arrows are exploded into their lines, circles and texts on the layer of the block insert. Line types such as dashes, dimension styles and paper-space layouts with title blocks are not carried over.

Heights and coordinate precision

Real heights, such as contour elevations, are kept as a third coordinate; flat drawings get two. The coordinates are written with 7 decimals, about 1 cm on the ground, which keeps the file small without moving anything visibly.

About the formats

DXF

DXF (Drawing Exchange Format) is the open exchange format of AutoCAD, published by Autodesk since 1982. Surveyors, architects and engineers use it to pass CAD drawings between programs. A DXF holds lines, polylines, arcs, circles, text, hatches and blocks on named layers, but no attribute table and no coordinate system.

  • Plain text (or binary) with drawing entities on named layers; blocks are reusable symbols inserted many times.
  • There is no attribute table: besides the geometry, an entity has a layer, a color, a line type and, for text, the text itself.
  • The coordinate system is not stored; coordinates are just numbers, often in a national grid or in local site units.
  • DWG is AutoCAD's own binary format, not the same thing as DXF.

GeoJSON

GeoJSON is a plain-text JSON format for geographic features, standardized as RFC 7946 in 2016. It is the native format of web maps such as Leaflet, MapLibre and Mapbox, and of many APIs.

  • Coordinates are WGS84 longitude, latitude (in that order).
  • Points, lines and polygons can be mixed in one file.
  • Properties can be any JSON value, with no limit on field name length.

Frequently asked questions

Can I get the GeoJSON in my national grid instead of longitude and latitude?

Not on this page, because RFC 7946 GeoJSON must be in WGS84 and most web maps expect it. If you need the drawing's own grid, convert the DXF to a shapefile or GeoPackage instead, which keep a projected system.

Why are the lines black on my map?

CAD color 7 is drawn white on a dark CAD screen and black on paper; it is written as #000000. Other colors are kept as they are. The simplestyle properties stroke and fill hold the same color, so you can also use them in your own map style.

How do I find the EPSG code of a drawing?

Ask whoever made it, or use the suggestions that appear under the field after the DXF is read: they list the coordinate systems in which the drawing's numbers make sense, and the map preview shows where each one puts it.

Is my drawing uploaded?

No. The DXF is read and converted by your browser on your own computer, and nothing is sent to a server.

Can I convert a GeoJSON back to DXF?

Yes, with the GeoJSON to DXF converter, which converts longitude and latitude to UTM metres or your national grid and puts each file on its own CAD layer.