OnlineMapMaker

WKB Viewer: Open Well-Known Binary on a Map

Paste WKB or EWKB hex from your database, or open a binary file, and see the geometry on a map. Every byte is explained, and a broken value shows the exact place of the error. Open fullscreen version →

Rate this tool:
Advertisement
Advertisement
Loading…
Need assistance with your GIS project?Explore Our Services

What is a WKB viewer?

Well-Known Binary (WKB) is the compact binary form of a geometry: a point, a line, a polygon or a group of them. It is defined in the OGC Simple Features standard, together with its readable sister format WKT (Well-Known Text). Databases and libraries use WKB to store and move geometry, because numbers stay exact and take little space.

The problem is that people cannot read it. A query in PostGIS returns a long line like 0101000020E6100000..., and you cannot tell whether it is a point in Berlin, a polygon in the wrong place or a damaged value. This WKB viewer decodes that line in your browser, draws it on a map and shows the type, the coordinate system (SRID), the byte order, the number of vertices and the extent.

My advice: when a geometry looks wrong, look at the bytes before you blame your map. The byte table in this tool names each field, so you can see at once if the SRID is missing, if latitude and longitude are swapped, or if the value was cut off while copying.

Advertisement
Advertisement

How WKB is built: a point, byte by byte

Here is POINT (2 4) in little-endian WKB. The whole value is 010100000000000000000000400000000000001040: 21 bytes, written as 42 hexadecimal characters.

Bytes (hex)Meaning
01Byte order, 1 byte. 01 means little-endian (least significant byte first), 00 means big-endian.
01000000Geometry type, 4 byte integer. Read backwards in little-endian, this is 1: a point.
0000000000000040X (longitude), 8 byte IEEE 754 floating point number: 2.0
0000000000001040Y (latitude), 8 byte floating point number: 4.0

PostGIS writes the same point with its coordinate system as 0101000020E610000000000000000000400000000000001040. The type field is now 01000020: the number 1 with the flag 0x20000000, which says that a SRID follows. The next 4 bytes, E6100000, are the number 4326.

In big-endian the same point is 000000000140000000000000004010000000000000. Lines add a 4 byte point count before the coordinates. Polygons add a ring count and then a point count for each ring. In multi geometries every member is a complete WKB value with its own byte order and type.

WKB geometry type codes

The type code tells the decoder what follows. The ISO standard adds 1000 for geometries with Z (height), 2000 for M (measure) and 3000 for both.

Geometry type2DZMZM
Point1100120013001
LineString2100220023002
Polygon3100320033003
MultiPoint4100420043004
MultiLineString5100520053005
MultiPolygon6100620063006
GeometryCollection7100720073007
PolyhedralSurface15101520153015
TIN16101620163016
Triangle17101720173017

PostGIS EWKB marks Z and M differently: it sets the flag bits 0x80000000 (Z) and 0x40000000 (M) in the type code. This viewer reads both styles. Curved types (codes 8 to 12, such as CircularString) are recognized and reported, but not drawn.

WKB, EWKB and database blobs: which one do you have?

Several formats wrap the same geometry body in a different header. The viewer recognizes each one by its first bytes.

FormatHow it startsCoordinate systemWhere it comes from
WKB (OGC / ISO)00 or 01, then the type codeNot storedOGC / ISO standard, ST_AsBinary, Shapely, GEOS, GeoParquet
EWKB (PostGIS)00 or 01, type code with flag bitsOptional, inside the valuePostGIS: the text you see when you select a geometry column
GeoPackage blob47 50 (the letters GP)In the headerGeoPackage (.gpkg) geometry columns
SpatiaLite blob00, byte order, SRID, bounding box, 7CIn the headerSpatiaLite geometry columns; ends with FE
MySQL internal format4 byte SRID, then WKBIn the first 4 bytesMySQL and MariaDB internal geometry, for example HEX(geom)

If you need the text form, the viewer copies every geometry as WKT, or as EWKT when it has a SRID, for example SRID=4326;POINT (13.4 52.5).

How to view WKB online, step by step

The screenshots use the built-in sample, which holds real places in Berlin written in several of these formats, plus one value that is cut off on purpose.

Empty WKB Viewer with the input box, the Sample button and a world map
1
Step 1: Paste your WKB or open a file

Paste hex into the input box, one value per line, or press "Open file" for a .wkb, .bin, .hex, .txt or .csv file. You can also drop a file on the tool. Prefixes such as 0x and \x, whole result tables and Base64 are accepted.

WKB sample loaded, with a polygon, a line and points drawn over Berlin and a list of values
2
Step 2: Check the geometries on the map

Press "Sample" to try it. Every value appears in the list with its type and SRID. A green check mark means it was read, an orange mark means it needs a coordinate system, and a red cross means it is damaged.

Details panel and byte table of a selected polygon in the WKB Viewer
3
Step 3: Read the details and the bytes

Click a geometry in the list or on the map. The details show the format, type, dimensions, SRID, byte order, size, vertex count and extent. The byte table lists each field with its position, its hex bytes and its value.

Error message with the failing byte position for a cut off WKB value
4
Step 4: Find errors in damaged values

Select a value with a red cross. The viewer names the problem and the byte where it happens, for example a value that ends too early or a count that is larger than the data.

Coordinate system panel with an EPSG code field and the Swap X and Y option
5
Step 5: Set the coordinate system if needed

Plain WKB has no SRID. If its numbers are not longitude and latitude, type the EPSG code (for example 25833) or a PROJ string and press "Apply". Tick "Swap X and Y" when your values are written as latitude first.

Export buttons for GeoJSON, CSV, WKT and GeoJSON copy in the WKB Viewer
6
Step 6: Export GeoJSON, CSV or WKT

Download the geometries as GeoJSON (in longitude and latitude) or as a CSV table with WKT, or copy them to the clipboard. You can also change the color, line width and fill.

Advertisement
Advertisement

How to get WKB from your database or code

Any of these sources gives you a value that you can paste straight into the viewer.

PostGIS

Selecting a geometry column in psql or pgAdmin shows EWKB hex, SRID included. ST_AsBinary(geom) returns standard WKB without the SRID, and ST_AsEWKB(geom) keeps it.

MySQL and MariaDB

HEX(geom) gives the internal format (SRID plus WKB). HEX(ST_AsBinary(geom)) gives plain WKB. In MySQL 8, ST_AsBinary writes SRID 4326 as latitude first, so add the option axis-order=long-lat or tick "Swap X and Y" here.

GeoPackage and SpatiaLite

Both are SQLite files. The query SELECT hex(geom) FROM my_table; returns the stored blob. To browse a whole file instead, use the GeoPackage Viewer or the SQLite Viewer.

Python

Shapely gives geom.wkb_hex, and shapely.from_wkb() reads it back. GeoPandas can turn a whole column into hex with to_wkb(hex=True).

Ready to copy

These commands print hex values, one per row.

-- PostGIS
SELECT geom FROM roads LIMIT 20;                       -- EWKB hex, with SRID
SELECT encode(ST_AsBinary(geom), 'hex') FROM roads;    -- standard WKB hex

-- MySQL 8
SELECT HEX(geom) FROM places;                          -- SRID + WKB
SELECT HEX(ST_AsBinary(geom, 'axis-order=long-lat')) FROM places;

-- GeoPackage and SpatiaLite (SQLite)
SELECT hex(geom) FROM my_table;

# Python, Shapely 2
import shapely
print(shapely.Point(2, 4).wkb_hex)
print(shapely.from_wkb("010100000000000000000000400000000000001040"))

Common WKB problems and what they mean

These are the faults I would check first when a geometry fails to load.

The value ends too early
The text was cut while copying. Some database tools shorten long cells, so export the result to a file or copy the full cell.
Odd number of characters
Each byte needs two hex characters. One character is missing or one too many was copied.
Unknown geometry type
The bytes are not WKB, or they have another header in front of them. Check that you selected the geometry column.
The shape is in the wrong place
Latitude and longitude are swapped, or the coordinates are projected and need their EPSG code.
Nothing appears on the map
The numbers are outside the range of longitude and latitude. Enter the coordinate system, or check the SRID.
Advertisement
Advertisement

When a WKB viewer helps

Typical jobs where seeing the geometry saves time.

  1. Debugging a database query. Paste the result of a spatial query and see at once whether the buffer, intersection or union returned the shape you expected.
  2. Checking API and log data. Services often send geometry as hex or Base64. Decode it without writing a script.
  3. Finding a wrong SRID. The details panel shows the stored SRID, so you can spot data that says 4326 but holds meters.
  4. Repairing a broken import. When one row stops an import, the byte position of the error shows whether the value was cut off or has the wrong header.
  5. Teaching the format. The byte table connects the standard to real numbers, which is useful in a GIS or database class.
  6. Sharing a result. Turn hex from a database into GeoJSON or WKT that a colleague can open in any GIS.

Frequently asked questions

1. How do I open a WKB file?

Press "Open file" and choose the file, or drop it on the tool. A binary file may hold one geometry or several WKB geometries written one after another. A text file may hold one hex or Base64 value per line.

2. What is the difference between WKB and WKT?

They describe the same geometries. WKT is text such as POINT (2 4) that people can read. WKB is binary, usually shown as hex, which computers read faster and which keeps every digit of a coordinate.

3. What is the difference between WKB and EWKB?

EWKB is the PostGIS extension of WKB. It can store a SRID and marks Z and M with flag bits. Standard WKB has no place for a SRID.

4. Can I convert WKB to GeoJSON or WKT?

Yes. "Download GeoJSON" saves the geometries in longitude and latitude, "Copy WKT" copies them as text, and the CSV download lists type, SRID and WKT for each value. GeoJSON keeps Z values and drops M values.

5. Which coordinate systems are supported?

WGS 84 and similar geographic systems, Web Mercator, UTM zones and a set of national grids by EPSG code. For any other system, type its PROJ string in the coordinate system box.

6. Is my data uploaded?

No. Your browser decodes the values on your own computer. The map downloads background tiles, but your geometry is not sent anywhere.

7. How large can the input be?

Files up to 10 MB and up to 5,000 geometries at a time. For larger tables, filter the rows in your database first, or export the table to a GeoPackage.

8. Why does my MySQL geometry appear in the wrong place?

MySQL 8 returns SRID 4326 from ST_AsBinary with latitude first. Tick "Swap X and Y", or ask MySQL for axis-order=long-lat.

9. Are curved geometries supported?

Not yet. CircularString, CompoundCurve and CurvePolygon are reported by name. In PostGIS you can turn them into straight segments with ST_CurveToLine before you copy them.

Libraries and data

The WKB decoder is written for this tool. It uses these open projects.

Related tools

Datum differences below about 2 meters are ignored in coordinate conversion, so do not use the map for survey-grade work. Map tiles © OpenStreetMap contributors, drawn with Protomaps (hosted by KONAKTIVE), with CARTO as the fallback.

Muhammad Gulraiz Khan, GIS Expert and Founder of KONAKTIVE and OnlineMapMaker.com

About the Author

Muhammad Gulraiz Khan

GIS Expert & Consultant · Founder, KONAKTIVE

Muhammad Gulraiz Khan is a GIS expert with over a decade of professional experience delivering geospatial solutions for the energy sector, including projects for the World Bank, the International Finance Corporation (IFC), and USAID. He built OnlineMapMaker.com to make professional-grade mapping tools free and accessible to everyone.

Comments

Questions, tips or feedback about this tool? Share them below. Every comment is checked before it appears.

Leave a comment

Your email is not shown to others. We use it to tell you when your comment is approved and when someone replies.

0/1000
Loading question...

Solve the sum in the picture and type the result. The digits are tilted on purpose.

Do not put links, email addresses or phone numbers in your comment. You can post one comment every 5 minutes.

Advertisement
Advertisement