Skip to content

GPS eXchange file (.gpx)

.gpx file signature | application/octet-stream

GPS eXchange file (v1.1 schema)

Safe

Magic Bytes

Offset 0
3C 67 70 78 20 76 65 72 73 69 6F 6E 3D 22 31 2E 31

Sources: Gary Kessler

Extension

.gpx

MIME Type

application/octet-stream

Byte Offset

0

Risk Level

Safe

Validation Code

How to validate .gpx files in Python

Python
def is_gpx(file_path: str) -> bool:
    """Check if file is a valid GPX by magic bytes."""
    signature = bytes([0x3C, 0x67, 0x70, 0x78, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22, 0x31, 0x2E, 0x31])
    with open(file_path, "rb") as f:
        return f.read(17) == signature

How to validate .gpx files in Node.js

Node.js
function isGPX(buffer: Buffer): boolean {
  const signature = Buffer.from([0x3C, 0x67, 0x70, 0x78, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22, 0x31, 0x2E, 0x31]);
  return buffer.subarray(0, 17).equals(signature);
}

How to validate .gpx files in Go

Go
func IsGPX(data []byte) bool {
    signature := []byte{0x3C, 0x67, 0x70, 0x78, 0x20, 0x76, 0x65, 0x72, 0x73, 0x69, 0x6F, 0x6E, 0x3D, 0x22, 0x31, 0x2E, 0x31}
    if len(data) < 17 {
        return false
    }
    return bytes.Equal(data[:17], signature)
}

API Endpoint

GET /api/v1/gpx
curl https://filesignature.org/api/v1/gpx

See the full API documentation for all endpoints and parameters.

Frequently Asked Questions

What is a .gpx file?

A .gpx file is a GPS eXchange file file. GPS eXchange file (v1.1 schema)

What are the magic bytes for .gpx files?

The magic bytes for GPS eXchange file files are 3C 67 70 78 20 76 65 72 73 69 6F 6E 3D 22 31 2E 31 at byte offset 0. These bytes uniquely identify the file format regardless of the file extension.

How do I validate a .gpx file?

To validate a .gpx file, read the first bytes of the file and compare them against the known magic bytes (3C 67 70 78 20 76 65 72 73 69 6F 6E 3D 22 31 2E 31) at offset 0. This is more reliable than checking the file extension alone, as extensions can be renamed.

What is the MIME type for .gpx files?

There is no officially registered MIME type for .gpx files. Systems typically use application/octet-stream as a generic fallback when handling this format.

Is it safe to open .gpx files?

GPS eXchange file (.gpx) files are generally safe to open. They are classified as low risk because they primarily contain data rather than executable code. However, always ensure files come from a trusted source.