# GeoJSON Converter for CSV, KML and GPX (`plainpipe/geojson-converter`) Actor

Convert CSV lat/lon, KML and GPX to GeoJSON, or GeoJSON to CSV, with validation, bbox and centroids. Use when you need map data in another format or checked.

- **URL**: https://apify.com/plainpipe/geojson-converter.md
- **Developed by:** [Plain Pipe](https://apify.com/plainpipe) (community)
- **Categories:** Developer tools, Automation
- **Features:** Limited permissions
- **Stats:** 2 total users, 1 monthly users, 100.0% runs succeeded, 0 bookmarks
- **User rating**: No ratings yet

## Pricing

$0.50 / 1,000 results

This Actor is paid per event. You are not charged for the Apify platform usage, but only a fixed price for specific events.

Learn more: https://docs.apify.com/actors/running/actors-in-store.md#pay-per-event

## What's an Apify Actor?

An Actor is a serverless cloud program that runs on the Apify platform. It has two run modes.
In Batch mode, an Actor accepts a well-defined JSON input, performs an action which can take anything from a few seconds to a few hours,
and optionally produces a well-defined JSON output, datasets with results, or files in key-value store.
In Standby mode, an Actor provides a web server which can be used as a website, API, or an MCP server.

Apify vocabulary and the platform model are defined once, in the agent quickstart at https://apify.com/agents.md.

## How to integrate an Actor?

If asked about integration, you help developers integrate Actors into their projects.
You adapt to their stack and deliver integrations that are safe, well-documented, and production-ready.

Do not guess an integration path. Every one of them is in the agent quickstart at https://apify.com/agents.md: the Apify MCP server, Agent Skills with the Apify CLI, the JavaScript and Python clients, the REST API, and the account-free path for an agent with no human to sign in. It also carries the rule on stating cost before the first paid run.

For examples already wired to this Actor's own input schema, see the [API](#api) section below.

Each client library has reference documentation the quickstart does not restate: [JavaScript/TypeScript](https://docs.apify.com/api/client/js/docs.md) (`npm install apify-client`) and [Python](https://docs.apify.com/api/client/python/docs.md) (`pip install apify-client`).

# README

## GeoJSON Converter for CSV, KML and GPX

Convert CSV lat/lon, KML and GPX to GeoJSON, or GeoJSON to CSV with centroids. Validates GeoJSON and returns bbox and feature counts.

**Use this when:** you have points or tracks as CSV, KML, GPX or GeoJSON and need them as valid GeoJSON or as a flat CSV with coordinates.

### Why this one

- $0.50 per 1,000 results, one result per feature (or per file in file mode).
- Each row includes `valid` and `issues` from a GeoJSON check, plus `bbox`, centroid `longitude`/`latitude` and `geometryType`; file mode also saves the full .geojson and a centroid CSV.
- Format is detected from the content; column names like lat/latitude/y are found automatically. No browser, no proxy, no external service.
- The prefilled example (3 cities) finishes in under 3 seconds in our test runs; 7 edge-case inputs are checked before each release.

### What it does

Paste geo data, give links, or upload a file, and the Actor turns it into GeoJSON features. It reads CSV files with latitude and longitude columns (each row becomes a point), GeoJSON (FeatureCollection, a single Feature, a bare geometry, or a JSON array of features), KML placemarks, and GPX waypoints, routes and tracks. KML and GPX are read with the open-source `@tmcw/togeojson` and `@xmldom/xmldom` libraries; CSV is parsed with `papaparse` (comma, semicolon or tab, and decimal commas such as `48,1351`). Bounding boxes and centroids are computed by the Actor itself.

GeoJSON input is also checked against the structure rules of RFC 7946: geometry types, positions that are `[longitude, latitude]` numbers inside the valid ranges, polygon rings that are closed and have at least four positions, and line strings with at least two positions. Problems are listed per feature, so you can find the broken record quickly.

### Use cases

- Turn a spreadsheet of store or site locations (CSV with lat/lon) into GeoJSON for a web map.
- Convert a GPX track from a GPS device, or a KML file from a mapping tool, into GeoJSON.
- Flatten a GeoJSON file into a CSV with one line per feature, its centroid and its properties.
- Check a GeoJSON file before loading it into a database or map library, and find features with open rings or swapped coordinates.
- Get the overall bounding box and feature counts of a geo file to set a map's initial view.

### How to use it

1. Paste your data into **Input text**, add file links to **Input URLs**, or upload one file. The prefilled example is a small CSV with three cities and needs no network access.
2. Choose the **Output mode**: **One row per feature** (longitude/latitude, bbox, validation and properties per feature; export as CSV for GeoJSON to CSV), or **One row per file** (counts, overall bbox and validation summary, with the full `.geojson` and a centroid CSV saved in the key-value store).
3. Optional: set the CSV latitude and longitude column names if they are not detected.
4. Set **Max results** and run the Actor.
5. Export the dataset as JSON, CSV or Excel, or read it through the Apify API.

### Input

| Field | What it does | Default | Example |
| --- | --- | --- | --- |
| `inputText` | Geo data pasted as text (CSV, GeoJSON, KML or GPX) | none | `name,lat,lon` + `Paris,48.8566,2.3522` |
| `inputUrls` | Direct links to CSV, GeoJSON, KML or GPX files; each link is converted separately | `[]` | `["https://example.com/places.geojson"]` |
| `inputFile` | One uploaded file, in addition to text and links | none | an uploaded `track.gpx` |
| `inputFormat` | `auto` (detected from content), `csv`, `geojson`, `kml` or `gpx` | `auto` | `csv` |
| `outputMode` | `features` (one row per feature) or `file` (one row per input, files in the key-value store) | `features` | `file` |
| `latColumn` | CSV latitude column; empty detects `lat`, `latitude` or `y` | empty | `Breite` |
| `lonColumn` | CSV longitude column; empty detects `lon`, `lng`, `long`, `longitude` or `x` | empty | `Länge` |
| `keepRowsWithoutCoordinates` | Keep CSV rows without numeric coordinates as features with `null` geometry | `false` | `true` |
| `includeGeometry` | Add the full geometry to each row in features mode | `true` | `false` |
| `coordinatePrecision` | Decimal places for computed longitude, latitude and bbox (geometry kept as given) | `6` | `3` |
| `maxItems` | Maximum results: features in features mode, files in file mode | `100` | `5000` |

### Output

Features mode, one row per feature. Example from the prefilled CSV:

```json
{
  "source": "inputText",
  "inputFormat": "csv",
  "featureIndex": 0,
  "featureId": null,
  "name": "Paris",
  "geometryType": "Point",
  "longitude": 2.3522,
  "latitude": 48.8566,
  "bbox": [2.3522, 48.8566, 2.3522, 48.8566],
  "positionCount": 1,
  "valid": true,
  "issues": [],
  "properties": { "name": "Paris", "country": "France" },
  "geometry": { "type": "Point", "coordinates": [2.3522, 48.8566] }
}
```

| Field | Meaning |
| --- | --- |
| `longitude`, `latitude` | The point, or the centroid of a line or polygon |
| `bbox` | `[minLon, minLat, maxLon, maxLat]` of the feature |
| `valid`, `issues` | GeoJSON validation result and the list of problems, e.g. `ring is not closed` |
| `properties` | The feature's properties (CSV: every non-coordinate column) |
| `geometry` | Full GeoJSON geometry (when `includeGeometry` is on) |

File mode, one row per input file:

```json
{
  "source": "inputText",
  "inputFormat": "kml",
  "featureCount": 3,
  "geometryCounts": { "Polygon": 1, "LineString": 1, "Point": 1 },
  "bbox": [2, 48, 2.5, 48.85],
  "bboxCenter": [2.25, 48.425],
  "positionCount": 8,
  "valid": true,
  "invalidFeatureCount": 0,
  "issues": [],
  "notes": [],
  "geojsonKey": "1-inputText.geojson",
  "geojsonUrl": "https://api.apify.com/v2/key-value-stores/<store id>/records/1-inputText.geojson",
  "csvKey": "1-inputText.csv",
  "csvUrl": "https://api.apify.com/v2/key-value-stores/<store id>/records/1-inputText.csv",
  "sizeBytes": 422
}
```

Centroids: polygons use the area-weighted centroid (holes are subtracted), lines use the length-weighted midpoint, multi-points use the mean position. For a mixed GeometryCollection the highest dimension wins. A polygon centroid can fall outside a strongly concave shape; it is not a "point on surface".

### Pricing

Pay per result: **$0.50 per 1,000 results** ($0.0005 per result). One result is one feature row in features mode, or one file row in file mode. You only pay for results the Actor returns. Set a maximum total charge on the run to cap your spend.

### Limits

- Files up to 50 MB each, UTF-8 text. Links must point straight at the file. Zipped KMZ files are not read; unzip them to KML first.
- Coordinates are treated as WGS84 longitude/latitude. Projected coordinate systems are not reprojected; their values are flagged as out of range.
- Validation covers structure and coordinate ranges. It does not check ring winding order, self-intersections or overlapping polygons.
- Only GeoJSON input is validated; KML and GPX are converted as the library reads them. KML styles, network links and ground overlays are not carried over.
- Bbox and centroid math is planar on longitude/latitude; it does not handle geometries that cross the 180th meridian.
- CSV input only produces points. The first line must be the header row.
- All features of a file are held in memory, so very large files need more run memory.
- Sources that cannot be read or parsed are skipped with a warning; if nothing is produced the run fails and nothing is charged.

### FAQ

**How much does a conversion cost?**
In features mode you pay per feature: 2,000 features cost $1.00. In file mode you pay one result per input file, and the `.geojson` and CSV files in the key-value store are free.

**Are invalid features charged or dropped?**
Invalid GeoJSON features are still returned with `valid: false` and an `issues` list, so you can fix them; they count as results. Sources that cannot be read at all are skipped and not charged.

**My CSV uses other column names. What do I do?**
Set `latColumn` and `lonColumn`, for example `Breite` and `Länge`. If the columns are not found, the error lists the column names in the file.

**Can I clean or merge the CSV before converting?**
Yes. Merge several location files and remove duplicates with the Plain Pipe Actor **Merge CSV Files and Remove Duplicates**, or convert an Excel sheet first with **Excel XLSX to JSON and CSV Converter**.

**Can I run it on a schedule or from my own code?**
Yes. Use Apify Schedules to convert a file that is updated at the same link, or start runs through the Apify API, webhooks or integrations such as Make and Zapier.

### Legal and data

This Actor processes only what you give it or public, non-personal technical data. It does not log in anywhere, does not collect personal data, and does not bypass paywalls, CAPTCHAs or access controls. You are responsible for having the right to process the inputs you provide.

### Support

Open an issue on the Issues tab. Issues are answered within 14 days.

Built and maintained by Plain Pipe.

# Actor input Schema

## `inputText` (type: `string`):

Paste geo data here: CSV with latitude and longitude columns (e.g. name,lat,lon then Paris,48.8566,2.3522), GeoJSON (FeatureCollection, Feature or geometry), KML or GPX. The format is detected from the content.

## `inputUrls` (type: `array`):

Direct links to CSV, GeoJSON, KML or GPX files, one per line, e.g. https://raw.githubusercontent.com/<owner>/<repo>/main/places.geojson. Use the raw file link, not a web page that shows the file. Each link is read and converted separately.

## `inputFile` (type: `string`):

Or upload one CSV, GeoJSON, KML or GPX file here, in addition to the text and links. Example: a track.gpx from a GPS device.

## `inputFormat` (type: `string`):

Leave on auto-detect (default), or force one format for every source, e.g. csv for a .txt file with lat/lon columns.

## `outputMode` (type: `string`):

Features: one dataset row per output feature (export the dataset as CSV for one line per feature with longitude/latitude). File: one dataset row per input file with counts, bbox and validation, and the full FeatureCollection (.geojson) plus a centroid CSV saved in the key-value store.

## `latColumn` (type: `string`):

Name of the latitude column in CSV input, e.g. Breite or y_coord. Leave empty (default) to detect lat, latitude or y.

## `lonColumn` (type: `string`):

Name of the longitude column in CSV input, e.g. Länge or x_coord. Leave empty (default) to detect lon, lng, long, longitude or x.

## `keepRowsWithoutCoordinates` (type: `boolean`):

Off (default): CSV rows whose latitude or longitude is empty or not a number are skipped. On: keep them as features with null geometry, e.g. to see which addresses still need coordinates.

## `includeGeometry` (type: `boolean`):

On (default): in features mode, add the full GeoJSON geometry to each row. Turn off for compact rows with only centroid and bbox, e.g. for a CSV export.

## `coordinatePrecision` (type: `integer`):

Decimal places for computed longitude, latitude and bbox values (default 6, about 10 cm; e.g. 3 for about 100 m). Geometry coordinates are kept as given.

## `maxItems` (type: `integer`):

Stop after this many results: features in features mode, files in file mode (default 100, e.g. 5000). You are charged per result.

## Actor input object example

```json
{
  "inputText": "name,country,lat,lon\nParis,France,48.8566,2.3522\nTokyo,Japan,35.6762,139.6503\nNew York,United States,40.7128,-74.0060",
  "inputFormat": "auto",
  "outputMode": "features",
  "keepRowsWithoutCoordinates": false,
  "includeGeometry": true,
  "coordinatePrecision": 6,
  "maxItems": 10
}
```

# Actor output Schema

## `results` (type: `string`):

No description

# API

You can run this Actor programmatically using our API. Below are code examples in JavaScript, Python, and CLI, as well as the OpenAPI specification and MCP server setup.

## JavaScript example

```javascript
import { ApifyClient } from 'apify-client';

// Initialize the ApifyClient with your Apify API token
// Replace the '<YOUR_API_TOKEN>' with your token
const client = new ApifyClient({
    token: '<YOUR_API_TOKEN>',
});

// Prepare Actor input
const input = {
    "inputText": `name,country,lat,lon
Paris,France,48.8566,2.3522
Tokyo,Japan,35.6762,139.6503
New York,United States,40.7128,-74.0060`,
    "maxItems": 10
};

// Run the Actor and wait for it to finish
const run = await client.actor("plainpipe/geojson-converter").call(input);

// Fetch and print Actor results from the run's dataset (if any)
console.log('Results from dataset');
console.log(`💾 Check your data here: https://console.apify.com/storage/datasets/${run.defaultDatasetId}`);
const { items } = await client.dataset(run.defaultDatasetId).listItems();
items.forEach((item) => {
    console.dir(item);
});

// 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/js/docs

```

## Python example

```python
from apify_client import ApifyClient

# Initialize the ApifyClient with your Apify API token
# Replace '<YOUR_API_TOKEN>' with your token.
client = ApifyClient("<YOUR_API_TOKEN>")

# Prepare the Actor input
run_input = {
    "inputText": """name,country,lat,lon
Paris,France,48.8566,2.3522
Tokyo,Japan,35.6762,139.6503
New York,United States,40.7128,-74.0060""",
    "maxItems": 10,
}

# Run the Actor and wait for it to finish
run = client.actor("plainpipe/geojson-converter").call(run_input=run_input)

# Fetch and print Actor results from the run's dataset (if there are any)
print(f"💾 Check your data here: https://console.apify.com/storage/datasets/{run.default_dataset_id}")
for item in client.dataset(run.default_dataset_id).iterate_items():
    print(item)

# 📚 Want to learn more 📖? Go to → https://docs.apify.com/api/client/python/docs/quick-start

```

## CLI example

```bash
echo '{
  "inputText": "name,country,lat,lon\\nParis,France,48.8566,2.3522\\nTokyo,Japan,35.6762,139.6503\\nNew York,United States,40.7128,-74.0060",
  "maxItems": 10
}' |
apify call plainpipe/geojson-converter --silent --output-dataset

```

## MCP server setup

```json
{
    "mcpServers": {
        "apify": {
            "type": "http",
            "url": "https://mcp.apify.com/?tools=fetch-actor-details,plainpipe/geojson-converter"
        }
    }
}
```

The hosted server signs you in with OAuth on first connect, so no API token belongs in this config. Clients without OAuth support can send an `Authorization: Bearer <APIFY_API_TOKEN>` header instead, using a token from API & Integrations in Apify Console (https://console.apify.com/settings/integrations).

## OpenAPI specification

Download the OpenAPI definition: https://api.apify.com/v2/actors/MbdqlkC4Uzfi0Mybq/builds/9Bbt70be8FnuETINT/openapi.json
