> ## Documentation Index
> Fetch the complete documentation index at: /documents/llms.txt
> Use this file to discover all available pages before exploring further.

# ST_AsBinary, ST_AsWKB

> Serializes a native GEOMETRY or GEOGRAPHY value as WKB.

Serializes a native `GEOMETRY` or `GEOGRAPHY` value as Well-Known Binary (WKB). `ST_AsWKB` is an alias of `ST_AsBinary`.

## Syntax

```sql theme={null}
VARBINARY ST_AsBinary(GEOMETRY geometry)
VARBINARY ST_AsBinary(GEOGRAPHY geography)
VARBINARY ST_AsWKB(GEOMETRY geometry)
VARBINARY ST_AsWKB(GEOGRAPHY geography)
```

The function preserves all seven OGC geometry families and `EMPTY` members. A `NULL` input returns `NULL`.

## Example

```SQL theme={null}
SELECT hex(ST_AsBinary(ST_GeogFromText('POINT (1 2)')));
```

```text theme={null}
0101000000000000000000F03F0000000000000040
```

The same serializer names accept native `GEOMETRY` values:

```SQL theme={null}
SELECT hex(ST_AsBinary(ST_GeomFromText('POINT (1 2)', 'EPSG:3857')));
```

## Keywords

ST\_ASBINARY, ST\_ASWKB, GEOMETRY, GEOGRAPHY, WKB

## Related data types

[GEOGRAPHY](/documents/4.2/sql-reference/data-types/spatial-types/GEOGRAPHY.md), [GEOMETRY](/documents/4.2/sql-reference/data-types/spatial-types/GEOMETRY.md), [VARBINARY](/documents/4.2/sql-reference/data-types/string-type/BINARY.md)


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.