# GeoJSON to TypeScript

**An object with 3 nested shapes.**

## Input

```json
{
  "type": "FeatureCollection",
  "features": [
    {
      "type": "Feature",
      "geometry": { "type": "Point", "coordinates": [-97.74, 30.27] },
      "properties": { "name": "Austin" }
    }
  ]
}
```

## TypeScript

```typescript
export interface Root {
  type: string;
  features: Feature[];
}

export interface Feature {
  type: string;
  geometry: Geometry;
  properties: Property;
}

export interface Geometry {
  type: string;
  coordinates: number[];
}

export interface Property {
  name: string;
}
```

## Zod

```typescript
import { z } from 'zod';

export const PropertySchema = z.object({
  name: z.string(),
});

export const GeometrySchema = z.object({
  type: z.string(),
  coordinates: z.array(z.number()),
});

export const FeatureSchema = z.object({
  type: z.string(),
  geometry: GeometrySchema,
  properties: PropertySchema,
});

export const RootSchema = z.object({
  type: z.string(),
  features: z.array(FeatureSchema),
});
```

---

Canonical URL: https://json-to-types.gumballtools.com/types/geojson-to-typescript
JSON API: `POST https://json-to-types.gumballtools.com/api/v1/convert`
MCP endpoint: `https://json-to-types.gumballtools.com/api/mcp`
