WKT to WKB Converter
Common when moving human-readable WKT into the compact binary form spatial databases store and index.
Common issues converting WKT to WKB
- WKB is geometry-only — any attributes alongside your WKT must be carried separately and re-joined by row order after conversion.
- Plain WKB carries no SRID. If you need the coordinate system embedded, your database expects EWKB (an SRID-prefixed variant); set the CRS so the output includes it where supported.
- Coordinates are stored as IEEE-754 doubles, so the encoding is lossless and round-trips back to identical WKT.
- Output is hex-encoded by default so it pastes straight into SQL and ST_GeomFromWKB; switch to raw bytes only if your client expects a bytea literal.
Frequently asked questions
Is WKB smaller than WKT?
Yes — typically 2–4× smaller. Coordinates become 8-byte doubles with no delimiters or decimal text. That compactness is why PostGIS stores geometry as WKB internally.
Can I load the output straight into PostGIS?
Yes. Pass the hex to ST_GeomFromWKB(decode('<hex>','hex')), or ST_GeomFromEWKB if you included an SRID.
Which byte order does the output use?
Little-endian (NDR) — the dominant convention and what PostGIS emits from ST_AsBinary.
Does GEOMETRYCOLLECTION survive?
Yes. WKB represents collections natively, so mixed-type geometries round-trip without being split.