osm-pbf-parser is a Node.js library designed for streaming parsing of OpenStreetMap Protocol Buffer (PBF) files. It processes binary PBF data, converting it into a stream of JavaScript objects representing OSM nodes, ways, and relations. The current stable version is 2.3.0. This library is designed for handling large `.pbf` files efficiently by processing them in a streaming fashion, avoiding the need to load the entire file into memory. It further differentiates itself by exposing `BlobParser` and `BlobEncoder` components, which allow for distributing binary work units and facilitating parallel processing of PBF data blobs, a feature useful for high-performance data extraction and transformation workflows. Due to its age (last updated in 2021) and CommonJS-only nature, it should be considered for projects that can tolerate an unmaintained dependency or require its specific streaming and parallel processing features for older Node.js environments.
npm install osm-pbf-parserVerified import paths — ran on the pinned version, not inferred.
Demonstrates streaming parsing of an OpenStreetMap PBF file, logging the type, ID, and tags of each item (node, way, or relation) to the console.
For new projects, consider actively maintained alternatives. If using this library, be prepared to fork and maintain the codebase yourself for critical updates or compatibility issues.
Ensure your project or file uses CommonJS (`require()`) for importing `osm-pbf-parser`. For modern ESM projects, you might need to use a CJS wrapper or consider alternative streaming PBF parsers that support ESM.
Regularly verify compatibility with your target OSM PBF file versions. If parsing issues arise with newer files, manual adjustments or migration to a different parser may be necessary.
Ensure your Node.js project or file is configured for CommonJS, or refactor to use `require()` within a CJS context. For modern ESM projects, consider a dynamic `import()` or an alternative parser.
Use the correct CommonJS `require` syntax: `const parseOSM = require('osm-pbf-parser');`.Verify the integrity of your PBF file. If the file is valid, consider if the PBF schema has evolved beyond what this unmaintained library supports. Upgrading the `pbf` dependency (if compatible) or using a different, actively maintained parser might be required.