Registry / serialization / parse-svg-path

parse-svg-path

JSON →
library0.1.2jsnpmunverified

parse-svg-path is a highly minimal JavaScript library designed to parse SVG path data strings into a simple array-of-arrays format. Published in 2014, with its last update 10 years ago, it remains at version 0.1.2, indicating it is no longer actively maintained. Its primary differentiator is its simplicity and small footprint, directly outputting commands as `[command, arg1, arg2, ...]`. While functional for basic SVG paths, it lacks features found in more modern and actively developed alternatives like `svg-path-parser` or `svgpath`, which offer more advanced manipulation, normalization, or broader SVG feature support. Due to its age, it primarily supports CommonJS modules and does not offer native ESM support.

npm install parse-svg-path
INSTALL
IMPORT
SIG · PARSE-SVG-PATH
P
parse-svg-path
serializationjavascriptv0.1.2
Install
Import
Disk
Pass rate
0/ 6
Env Coverage0 / 6
glibc
1822
musl
1822
Install & Compatibility
Where this runs
tested against v? · npm install
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
musl
node 18226 runs
build_error
glibc
node 18226 runs
build_error
Code
Verified usage

Verified import paths — ran on the pinned version, not inferred.

parse
const parse = require('parse-svg-path')
This package is CommonJS-only due to its age (last updated 10 years ago). There is no native ESM export.
parse
import parse from 'parse-svg-path'
import { parse } from 'parse-svg-path'
While Node.js might allow this syntax for CJS modules, it's not a native ESM export. The package exports a default function.

Demonstrates how to import and use the `parse` function to convert an SVG path string into an array of command arrays, including basic and complex paths.

const parse = require('parse-svg-path'); const svgPathData = 'M10 10 L100 10 L50 90 Z'; const parsedCommands = parse(svgPathData); console.log('Original SVG Path Data:', svgPathData); console.log('Parsed Commands:', JSON.stringify(parsedCommands, null, 2)); // Example with relative commands and shorthand const complexPathData = 'm1 2 3 4 C10 20 30 40 50 60 s70 80 90 100'; const parsedComplexCommands = parse(complexPathData); console.log('\nComplex SVG Path Data:', complexPathData); console.log('Parsed Complex Commands:', JSON.stringify(parsedComplexCommands, null, 2)); /* Expected output: Original SVG Path Data: M10 10 L100 10 L50 90 Z Parsed Commands: [ ["M",10,10], ["L",100,10], ["L",50,90], ["Z"] ] Complex SVG Path Data: m1 2 3 4 C10 20 30 40 50 60 s70 80 90 100 Parsed Complex Commands: [ ["m",1,2], ["l",3,4], ["C",10,20,30,40,50,60], ["s",70,80,90,100] ] */
Debug
Known issues
breakingThis package is abandoned and has not been updated in over 10 years. It may contain unpatched security vulnerabilities or not fully comply with modern SVG path specifications.
fix
Consider migrating to actively maintained alternatives like `svg-path-parser` or `svgpath` for better security, features, and modern JavaScript support.
affects: >=0.1.0
gotchaThe library is CommonJS-only and does not provide native ES Module exports. Direct `import { parse } from 'parse-svg-path'` will likely fail in strict ESM environments without a CommonJS wrapper or bundler.
fix
Use `const parse = require('parse-svg-path');` in CommonJS environments. For ESM, you might need dynamic `import()` or rely on bundler configurations to handle CJS modules.
affects: >=0.1.0
gotchaThe parser is minimal and might not handle all edge cases or newer SVG path syntax features introduced since its last update in 2014.
fix
Thoroughly test with your specific SVG path data. For complex or dynamically generated paths, a more robust parser is recommended.
affects: >=0.1.0
deprecatedThe project's README explicitly recommends alternative libraries (`hughsk/svg-path-parser` or `nfroidure/SVGPathData`) for 'delux' or 'streaming' models, implying `parse-svg-path` is intended for very basic use cases.
fix
Evaluate your parsing needs; if you require more than basic command extraction, use the recommended alternatives or other actively developed solutions.
affects: >=0.1.0
Errors
Common errors & fixes
require is not defined
Attempting to use `require()` in an ES module (ESM) context.
fix
This package is CommonJS. In an ESM file, try `import parse from 'parse-svg-path';` (may still require bundler configuration) or ensure your environment supports CommonJS modules.
TypeError: parse is not a function
Incorrect import statement or attempting to destructure a default export as a named export.
fix
Ensure you are importing the default export correctly: `const parse = require('parse-svg-path');` or `import parse from 'parse-svg-path';`.
Error: Command 'X' is not a valid SVG path command (or similar parsing error)
The parser might not recognize certain (potentially newer or malformed) SVG path commands due to its age and minimal nature.
fix
Verify your SVG path data against the SVG specification. If the path is valid, consider using a more modern and robust SVG path parser.
Upgrade
Version history
0.1.2latest on npm
Audit
Dependencies

No dependency data recorded yet.

Agent activity
2 hits · last 30 days
node
2
Resources
parse-svg-path — npm install parse-svg-path · libregistry