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

# GeoDataFrame.to_json

> Returns a GeoJSON representation of the GeoDataFrame as a string.

Returns a GeoJSON representation of the `GeoDataFrame` as a string.

## Signature

```python theme={"system"}
to_json(
    na: Literal['null', 'drop', 'keep'] = 'null',
    show_bbox: bool = False,
    drop_id: bool = False,
    to_wgs84: bool = False,
    **kwargs,
) -> str
```

## Parameters

<ParamField path="na" type="Literal['null', 'drop', 'keep']" default="'null'">
  Dictates how to represent missing (NaN) values in the output.

  * `null`: Outputs missing entries as JSON `null`.
  * `drop`: Removes the entire property from a feature if its
    value is missing.
  * `keep`: Outputs missing entries as `NaN`.
</ParamField>

<ParamField path="show_bbox" type="bool" default="False">
  If True, the `bbox` (bounds) of the geometries is included in the
  output.
</ParamField>

<ParamField path="drop_id" type="bool" default="False">
  If True, the GeoDataFrame index is not written to the 'id' field
  of each GeoJSON Feature.
</ParamField>

<ParamField path="to_wgs84" type="bool" default="False">
  If True, all geometries are transformed to WGS84 (EPSG:4326) to
  meet the [2016 GeoJSON specification](https://tools.ietf.org/html/rfc7946). When False, the current
  CRS is exported if it's set.
</ParamField>

<ParamField path="kwargs">
  Additional keyword arguments passed to `json.dumps()`.
</ParamField>

## Returns

<ResponseField name="return" type="str">
  A GeoJSON representation of the GeoDataFrame.
</ResponseField>

**See also**

* `GeoDataFrame.to_file`: Write a `GeoDataFrame` to a file, which can be
* `used for GeoJSON format.`

**See also**

* `GeoDataFrame.to_file`: write GeoDataFrame to file

## Examples

```python theme={"system"}
>>> from sedona.spark.geopandas import GeoDataFrame
>>> from shapely.geometry import Point
>>> d = {'col1': ['name1', 'name2'], 'geometry': [Point(1, 2), Point(2, 1)]}
>>> gdf = GeoDataFrame(d, crs="EPSG:3857")
>>> gdf.to_json()
'{"type": "FeatureCollection", "features": [{"id": "0", "type": "Feature", "properties": {"col1": "name1"}, "geometry": {"type": "Point", "coordinates": [1.0, 2.0]}}, {"id": "1", "type": "Feature", "properties": {"col1": "name2"}, "geometry": {"type": "Point", "coordinates": [2.0, 1.0]}}], "crs": {"type": "name", "properties": {"name": "urn:ogc:def:crs:EPSG::3857"}}}'
```


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