> ## 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.

# ST_MakeValid

Given an invalid geometry, create a valid representation of the geometry.

Collapsed geometries are either converted to empty (keepCollapsed=false) or a valid geometry of lower dimension (keepCollapsed=true).
Default is keepCollapsed=false.

<img src="https://mintcdn.com/wherobots/wLm_IRUSNlHZTHJP/images/sql-functions/ST_MakeValid/ST_MakeValid.svg?fit=max&auto=format&n=wLm_IRUSNlHZTHJP&q=85&s=39bed0fbf899062b5db3049e4e5dd476" alt="ST_MakeValid" width="400" height="130" data-path="images/sql-functions/ST_MakeValid/ST_MakeValid.svg" />

## Signatures

```sql theme={"system"}
ST_MakeValid (A: Geometry)
```

```sql theme={"system"}
ST_MakeValid (A: Geometry, keepCollapsed: Boolean)
```

## Parameters

<ParamField body="A" type="Geometry" required>
  The input geometry.
</ParamField>

<ParamField body="keepCollapsed" type="Boolean">
  The keep collapsed value.
</ParamField>

## Return type

<ResponseField type="Geometry">
  The resulting geometry.
</ResponseField>

## Example

```sql theme={"system"}
WITH linestring AS (
    SELECT ST_GeomFromWKT('LINESTRING(1 1, 1 1)') AS geom
) SELECT ST_MakeValid(geom), ST_MakeValid(geom, true) FROM linestring
```

```
+------------------+------------------------+
|st_makevalid(geom)|st_makevalid(geom, true)|
+------------------+------------------------+
|  LINESTRING EMPTY|             POINT (1 1)|
+------------------+------------------------+
```

<Note>
  In Sedona up to and including version 1.2 the behaviour of ST\_MakeValid was different.
</Note>

Be sure to check you code when upgrading. The previous implementation only worked for (multi)polygons and had a different interpretation of the second, boolean, argument.
It would also sometimes return multiple geometries for a single geometry input.
