vsvg-parser is a lightweight JavaScript library designed for parsing SVG (Scalable Vector Graphics) markup into a structured JavaScript object, suitable for both server-side (Node.js) and client-side (browser) environments. It was initially released in December 2014 and last updated in May 2019. The library is described by its original maintainers as being in 'early development,' and users should expect bugs and file issues. Its primary use case was to power the related `vsvg` library for SVG creation. The current stable version is 0.3.1. Due to its age and lack of recent updates, the project is no longer actively maintained. It focuses on providing a minimal, direct representation of SVG elements, attributes, and their hierarchical structure, without extensive manipulation capabilities, differentiating it from more feature-rich or actively developed SVG parsing solutions.
npm install vsvg-parserVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to import `vsvg-parser` using CommonJS and parse a simple SVG string, then log the resulting structured object and access elements.
For production or critical applications, consider using a more actively maintained and robust SVG parsing library. If you must use `vsvg-parser`, thoroughly audit its code and apply necessary patches.
For CommonJS, use `const parser = require('vsvg-parser');`. For ES modules in modern Node.js or browser environments, consider using a bundler (e.g., Webpack, Rollup) or a CDN that provides an ES module wrapper.You may need to create a custom declaration file (`vsvg-parser.d.ts`) to define types for the `parser` object and its `parse` method, or disable type checking for its usage.
Ensure you are calling `parser.parse(svgString)` after importing the default export: `const parser = require('vsvg-parser');` or `import parser from 'vsvg-parser';`Convert your import statement to `import parser from 'vsvg-parser';` and ensure your environment supports ES modules, possibly through a bundler or a shim service like Skypack for older CJS packages.
Create a `vsvg-parser.d.ts` file in your project with `declare module 'vsvg-parser';` or more detailed type definitions. Alternatively, install `@types/vsvg-parser` if it existed (which it doesn't for this package) or suppress the error using `@ts-ignore` (not recommended for production).
No dependency data recorded yet.