Installations
npm install svg-path-parse
Developer Guide
Typescript
No
Module System
CommonJS
Node Version
11.10.1
NPM Version
6.10.3
Score
76.3
Supply Chain
99.4
Quality
77.9
Maintenance
100
Vulnerability
100
License
Releases
Unable to fetch releases
Contributors
Unable to fetch Contributors
Languages
JavaScript (100%)
Love this project? Help keep it running — sponsor us today! 🚀
Developer
convertSvg
Download Statistics
Total Downloads
93,626
Last Day
15
Last Week
555
Last Month
1,948
Last Year
15,501
GitHub Statistics
MIT License
17 Stars
48 Commits
1 Forks
2 Watchers
1 Branches
1 Contributors
Updated on Jan 25, 2025
Bundle Size
17.89 kB
Minified
5.17 kB
Minified + Gzipped
Package Meta Information
Latest Version
1.1.3
Package Id
svg-path-parse@1.1.3
Unpacked Size
81.39 kB
Size
21.75 kB
File Count
28
NPM Version
6.10.3
Node Version
11.10.1
Total Downloads
Cumulative downloads
Total Downloads
93,626
Last Day
15.4%
15
Compared to previous day
Last Week
23.6%
555
Compared to previous week
Last Month
138.7%
1,948
Compared to previous month
Last Year
-33.2%
15,501
Compared to previous year
Daily Downloads
Weekly Downloads
Monthly Downloads
Yearly Downloads
svg-path-parse
This is a small library to normalise SVG paths based on those normalised paths.
Note: this package works with path data strings and Paths, not with full svg xml sources.
Install
npm install svg-path-parse
Usage
Takes an SVG path string. The following code…
1const { pathParse, serializePath } = require('svg-path-parse') 2 3const pathDatas = pathParse(__your_path__).getSegments() 4// const pathDatas = pathParse(__your_path__).normalize({round: 2, transform: 'translate(10, 10) scale(0.5)'}) 5// const pathDatas = pathParse(__your_path__).relNormalize({round: 2,transform: 'translate(10, 10) scale(0.5)'}) 6// const pathDatas = pathParse(__your_path__).absNormalize({round: 2,transform: 'translate(10, 10) scale(0.5)'}) 7// const pathDatas = pathParse(__your_path__).absCairo({round: 2,transform: 'translate(10, 10) scale(0.5)'}) 8// const pathDatas = pathParse(__your_path__).relCairo({round: 2,transform: 'translate(10, 10) scale(0.5)'}) 9 10// out put 11// { err: '', segments:[ { 'type': 'M', 'args' : [230, 230] }] } 12 13serializePath(pathDatas) 14 15console.log('pathDatas', serializePath(pathDatas)) 16 17// out put 18// M896 480C894.656 480 893.536 480.608 892.256 480.768C894.72 479.84 893.568 479.232 892.256 479.232z
API
getSegments
Convert all path commands,data format as follows:
1// example 2{ 3 err: '', 4 segments:[ 5 [ 'M', 230, 230 ], 6 [ 'A', 45, 45, 0, 1, 1, 275, 275 ], 7 [ 'L', 275, 230 ], 8 [ 'Z' ] 9 ] 10}
normalize
Convert all path commands,data format as follows:
1// example 2{ 3 err: '', 4 segments:[ 5 { 'type': 'M', 'args' : [230, 230] }, 6 { 'type': 'A', 'args' : [45, 45, 0, 1, 1, 275, 275] }, 7 { 'type': 'l', 'args' : [0, -45] }, 8 { 'type': 'z', 'args' : [] } 9 ] 10}
absNormalize
Converts all path commands to absolute, data format as follows:
1// example 2{ 3 err: '', 4 segments:[ 5 { 'type': 'M', 'args' : [230, 230] }, 6 { 'type': 'A', 'args' : [45, 45, 0, 1, 1, 275, 275] }, 7 { 'type': 'L', 'args' : [275, 230] }, 8 { 'type': 'Z', 'args' : [] } 9 ] 10}
relNormalize
Converts all path commands to relative. Useful to reduce output size, data format as follows:
1// example 2{ 3 err: '', 4 segments:[ 5 { type: 'M', args: [ 230, 230 ] }, 6 { type: 'a', args: [ 45, 45, 0, 1, 1, 45, 45 ] }, 7 { type: 'l', args: [ 0, -45 ] }, 8 { type: 'z', args: [] } 9 ] 10}
absCairo
Converts all path commands to absolute based on cairo and CairoSVG. Converts smooth curves Q/q/T/t/S/s with "missed" control point to generic curves (C), Converts V/v/H/h to lineto (L), data format as follows:
1// example 2{ 3 err: '', 4 segments:[ 5 { type: 'M', args: [ 230, 230 ] }, 6 { type: 'A', 7 args: [ 230, 230, 0, 1, 1, 45, 0, 45, 3.14, 1.57 ] }, 8 { type: 'L', args: [ 275, 230 ] }, 9 { type: 'Z', args: [] } 10 ] 11}
relCairo
Converts all path commands to relative on cairo and CairoSVG. Converts smooth curves Q/q/T/t/S/s with "missed" control point to generic curves (c), Converts V/v/H/h to lineto (l), data format as follows:
1// example 2{ 3 err: '', 4 segments:[ 5 { type: 'M', args: [ 230, 230 ] }, 6 { type: 'a', 7 args: [ 230, 230, 0, 1, 1, 45, 0, 45, 3.14, 1.57 ] }, 8 { type: 'l', args: [ 0, -45 ] }, 9 { type: 'z', args: [] } 10 ] 11}
serializePath
Returns final path string.
License

No vulnerabilities found.
Reason
no binaries found in the repo
Reason
0 existing vulnerabilities detected
Reason
license file detected
Details
- Info: project has a license file: LICENSE:0
- Info: FSF or OSI recognized license: MIT License: LICENSE:0
Reason
0 commit(s) and 0 issue activity found in the last 90 days -- score normalized to 0
Reason
Found 0/30 approved changesets -- score normalized to 0
Reason
no SAST tool detected
Details
- Warn: no pull requests merged into dev branch
Reason
no effort to earn an OpenSSF best practices badge detected
Reason
security policy file not detected
Details
- Warn: no security policy file detected
- Warn: no security file to analyze
- Warn: no security file to analyze
- Warn: no security file to analyze
Reason
project is not fuzzed
Details
- Warn: no fuzzer integrations found
Reason
branch protection not enabled on development/release branches
Details
- Warn: branch protection not enabled for branch 'master'
Score
3
/10
Last Scanned on 2025-02-10
The Open Source Security Foundation is a cross-industry collaboration to improve the security of open source software (OSS). The Scorecard provides security health metrics for open source projects.
Learn More