Converting...
Paste a WKT geometry above and click Convert to get formatted GeoJSON.
What Is WKT (Well-Known Text)?
Well-Known Text, or WKT, is a standard text markup language for representing vector geometry objects. It was defined by the Open Geospatial Consortium and is widely used by spatial databases such as PostGIS, SQL Server Spatial, and Oracle Spatial. A typical WKT string looks like POINT (30 10) or POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10)). Developers often copy these strings directly from database query results and need to turn them into GeoJSON for web maps and APIs.
WKT to GeoJSON Conversion Flow
Input
40 40, 20 40,
10 20, 30 10))
Well-Known Text from PostGIS or any spatial database.
Output
"type": "Polygon",
"coordinates": [
[[30,10], ...]
]
}
Pretty-printed RFC 7946 GeoJSON, ready for web maps.
How to Convert WKT to GeoJSON
Paste the raw WKT string into the input box above and click Convert to GeoJSON. The tool parses the geometry using the orb/encoding/wkt library, detects the geometry type, and marshals it to RFC 7946 GeoJSON. You can switch between the raw geometry output and a Feature wrapper, which is the format most mapping libraries expect when loading data. A one-click copy button lets you drop the result straight into your JavaScript, Python, or PostGIS workflow.
Common WKT Geometry Types
WKT supports the full range of simple feature geometries. Points are zero-dimensional, LineStrings are paths, and Polygons are closed rings. Multi-versions group several geometries of the same type, while GeometryCollection can mix types. This converter handles all of them and returns the matching GeoJSON type so you do not have to rewrite coordinates by hand.
WKT vs GeoJSON Syntax
| Geometry | WKT Example | GeoJSON Type |
|---|---|---|
| Point | POINT (30 10) | Point |
| LineString | LINESTRING (30 10, 10 30, 40 40) | LineString |
| Polygon | POLYGON ((30 10, 40 40, 20 40, 10 20, 30 10)) | Polygon |
| MultiPoint | MULTIPOINT ((10 40), (40 30), (20 20), (30 10)) | MultiPoint |
| MultiPolygon | MULTIPOLYGON (((30 20, 45 40, 10 40, 30 20)), ((15 5, 40 10, 10 20, 5 10, 15 5))) | MultiPolygon |
Why Developers Convert PostGIS WKT to GeoJSON
PostGIS can return geometry columns as WKT using functions like ST_AsText(geom). While WKT is perfect for storage and SQL, web mapping libraries such as Leaflet, Mapbox GL JS, and OpenLayers consume GeoJSON. Converting between the two formats is a routine step when building geospatial APIs or exporting query results. This tool removes the need to write a custom parser for every project.
Frequently Asked Questions
What is the difference between WKT and GeoJSON?
WKT is a compact text format defined by the OGC for describing geometry. GeoJSON is a JSON-based format defined by RFC 7946 and is the native language of web mapping. Both represent the same shapes, but GeoJSON is easier to parse in JavaScript and is accepted by most web APIs.
How do I convert a PostGIS geometry to GeoJSON?
You can use ST_AsGeoJSON(geom) directly in PostGIS, or pull the geometry with ST_AsText(geom) and paste the WKT into this converter. The converter returns pretty-printed GeoJSON you can use in Leaflet, Mapbox, or any GeoJSON-aware tool.
Does this tool support 3D WKT coordinates (Z values)?
The underlying parser accepts standard WKT including Z values, but the output follows RFC 7946 GeoJSON which primarily defines two-dimensional coordinates. 3D coordinates are generally preserved as a third number in the coordinate array, but always verify the result against your target application.
Can I convert MultiPolygon WKT to GeoJSON?
Yes. The converter handles MultiPolygon, MultiPoint, MultiLineString, and GeometryCollection inputs. It returns the corresponding GeoJSON Multi* type with all nested rings or coordinate arrays preserved.
Why is my WKT not parsing?
Common issues include mismatched parentheses, missing commas between coordinate pairs, or unsupported keywords. Make sure polygons have double parentheses around the outer ring and that coordinate tuples are separated by commas. The error message from the parser will point to the first problem it finds.
Is GeoJSON the same as RFC 7946?
RFC 7946 is the official IETF specification that defines the GeoJSON format. When people say GeoJSON, they usually mean RFC 7946. This converter produces standard RFC 7946 output with the recommended right-hand rule for polygon rings.