--- id: kml2geojson version: "6.0.0" license: MIT license_treatment: permissive maintenance: active --- # kml2geojson — A Python library to convert KML files to GeoJSON files License: permissive · Maintenance: active · Downloads: 208.0K/mo ## What it is and what it does kml2geojson is a Python library that translates KML (Keyhole Markup Language) files into GeoJSON format. It's designed as a lightweight, dependency-minimal alternative to GDAL, with a codebase adapted from the Node.js togeojson package. The library handles standard KML elements like Placemarks, GroundOverlays, and NetworkLinks, and converts them to valid GeoJSON FeatureCollections. Beyond basic conversion, it preserves KML styling information (colors, opacity, icons), can catalog all styles used in a document, optionally organizes output by KML folder structure, and supports typed ExtendedData via KML Schemas. It works both as a Python library and as a command-line tool (k2g), making it suitable for batch processing or integration into data pipelines. The package depends only on click for CLI support. Use it for: - Convert geographic data from Google Earth KML exports to GeoJSON for web mapping libraries like Leaflet or Mapbox. - Batch-process KML files from GPS devices or survey tools into a standardized format for GIS analysis. - Preserve KML styling (colors, icons) when migrating map data to web-based visualization platforms. - Extract and organize nested KML folder hierarchies into separate GeoJSON FeatureCollections for layered map rendering. - Parse KML with custom ExtendedData attributes and convert them to GeoJSON properties for downstream processing. ## Worth the install? AI-flagged interpretation of the facts above — verify before relying. Converts KML files to GeoJSON format, preserving styling, folder structure, and extended data while offering a lightweight alternative to GDAL. Yes. The package is actively maintained, has no known vulnerabilities, installs with minimal friction, and solves a specific problem (KML-to-GeoJSON conversion with styling preservation) that GDAL is often overkill for. Suitable for web-focused geospatial workflows where lightweight dependencies matter. ## Install pip install kml2geojson uv add kml2geojson poetry add kml2geojson ## Installing kml2geojson Before you install: Installs cleanly with a single runtime dependency (click). Actively maintained with a recent release (39 days ago) and support for current Python versions (3.11+). License in practice: MIT license permits commercial and private use with minimal restrictions—suitable for most projects that include proper attribution. Quickstart: pip install kml2geojson from kml2geojson import convert result = convert('input.kml') # result is a dict with 'feature_collections' key # Or from CLI: k2g input.kml output.geojson Requires Python 3.11 or later. Verify before relying: - Performance characteristics with large KML files (file size limits, conversion speed). - Completeness of KML 2.2 spec coverage beyond the documented feature set. - Behavior when KML contains unsupported or malformed geometry elements. ## Package facts - License: MIT (permissive) - Python support: supports_current - Install friction: low - Maintenance: active - Downloads: 208.0K/month (top 15,000 on PyPI) - Known vulnerabilities: none known ## Tags kml to geojson conversion, kml parser python, geographic data format conversion, kml styling preservation, lightweight kml converter, geojson from kml files, kml to geojson cli, geospatial, format-conversion, cli-tool [View on SkillFed](https://skillfed.io/packages/kml2geojson) · [View on PyPI](https://pypi.org/project/kml2geojson/)