This page follows Esri’s ESRI
Shapefile Technical Description (white paper J-7855, July 1998), read
2026-11-12.
A shapefile is at least three files with the same name: .shp (shapes),
.shx (index) and .dbf (attributes, one
row per shape, in the same order). Integers are 32-bit and doubles 64-bit IEEE; the
byte order is given for each field, because it changes.
File header
100 bytes, the same in .shp and .shx.
| Offset | Type | Order | Field |
|---|---|---|---|
0 | integer | big | File code, 9994. |
4 | 5 integers | big | Unused, zero. |
24 | integer | big | File length in 16-bit words, header included. |
28 | integer | little | Version, 1000. |
32 | integer | little | Shape type. All non-null shapes in a file have this type. |
36 | double | little | Xmin |
44 | double | little | Ymin |
52 | double | little | Xmax |
60 | double | little | Ymax |
68 | double | little | Zmin (0 when not used) |
76 | double | little | Zmax |
84 | double | little | Mmin |
92 | double | little | Mmax |
Records
Each .shp record is an 8-byte header and the contents.
| Offset | Type | Order | Field |
|---|---|---|---|
0 | integer | big | Record number, from 1. |
4 | integer | big | Content length in 16-bit words. Each record adds 4 + this value to the file length. |
8 | integer | little | Shape type of this record (the file’s type, or 0 for a null shape). |
The .shx file is the header, then 8 bytes per record: the record’s
offset in the .shp file and its content length, both big-endian and in
16-bit words. The first record’s offset is therefore 50. The .shx
header’s file length is 50 + 4 × the number of records.
Shape types
| Value | Shape | Value | Shape |
|---|---|---|---|
| 0 | Null shape | 18 | MultiPointZ |
| 1 | Point | 21 | PointM |
| 3 | PolyLine | 23 | PolyLineM |
| 5 | Polygon | 25 | PolygonM |
| 8 | MultiPoint | 28 | MultiPointM |
| 11 | PointZ | 31 | MultiPatch |
| 13 | PolyLineZ | ||
| 15 | PolygonZ |
Other values are reserved. “M” shapes add a measure to each point (such as a distance along a route); “Z” shapes add a height and optionally a measure.
Record contents
All little-endian, after the 4-byte shape type. Offsets count from the shape type.
Point, PointM, PointZ
X (double, offset 4), Y (12); PointM adds M (20); PointZ adds Z (20) and M (28). A null shape is just the type, 0.
MultiPoint
| Offset | Field |
|---|---|
4 | Bounding box: Xmin, Ymin, Xmax, Ymax (4 doubles) |
36 | NumPoints (integer) |
40 | Points: X, Y pairs (16 bytes each) |
PolyLine and Polygon
| Offset | Field |
|---|---|
4 | Bounding box (4 doubles) |
36 | NumParts (integer) |
40 | NumPoints (integer) |
44 | Parts: for each part, the index of its first point (integers) |
| 44 + 4 × NumParts | Points: X, Y pairs |
A polyline part is a connected line. A polygon part is a closed ring, its first and last points the same; the outer ring runs clockwise and holes run counter-clockwise, so the inside of the polygon is always on the right.
M and Z additions
The M forms of MultiPoint, PolyLine and Polygon add, after the points: Mmin, Mmax (doubles) and one M per point; the description marks these as optional. The Z forms add Zmin, Zmax and one Z per point, then the optional M range and values. Whether the optional part is there follows from the record’s content length.
Any floating-point value below −1038 means “no data”; the description uses this only for measures. Infinity and NaN are not allowed anywhere. In an empty shapefile the bounding box values are unspecified.
MultiPatch
Bounding box, NumParts, NumPoints, Parts, then PartTypes (one integer per part), then Points, Z range and values, and optionally M range and values. Part types:
| Value | Part type |
|---|---|
| 0 | Triangle strip |
| 1 | Triangle fan |
| 2 | Outer ring |
| 3 | Inner ring |
| 4 | First ring (of a polygon whose ring types are not known) |
| 5 | Ring (of such a polygon) |
Other files of a shapefile
The 1998 description covers only .shp, .shx and
.dbf. Other files found beside shapefiles, such as .prj
(the coordinate system), are not part of it and are not described here.