{"id":23648011,"url":"https://github.com/zillding/svg-to-url","last_synced_at":"2025-11-12T12:30:19.115Z","repository":{"id":22301501,"uuid":"95876946","full_name":"zillding/svg-to-url","owner":"zillding","description":"A utility to convert svg file to data url string","archived":false,"fork":false,"pushed_at":"2024-05-27T23:51:48.000Z","size":676,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-05-28T09:02:32.355Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":"https://www.npmjs.com/package/svg-to-url","language":"JavaScript","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/zillding.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2017-06-30T10:20:04.000Z","updated_at":"2024-05-30T01:57:15.528Z","dependencies_parsed_at":"2023-11-11T01:29:47.090Z","dependency_job_id":"48b66dae-1ec4-4d5f-8850-8fed10a19c3a","html_url":"https://github.com/zillding/svg-to-url","commit_stats":{"total_commits":91,"total_committers":5,"mean_commits":18.2,"dds":0.4725274725274725,"last_synced_commit":"d88b382c77bffede1dc6e58e41dfe7d3a71515ed"},"previous_names":[],"tags_count":7,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zillding%2Fsvg-to-url","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zillding%2Fsvg-to-url/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zillding%2Fsvg-to-url/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/zillding%2Fsvg-to-url/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/zillding","download_url":"https://codeload.github.com/zillding/svg-to-url/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":239600906,"owners_count":19666264,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-12-28T14:50:14.226Z","updated_at":"2025-11-12T12:30:19.074Z","avatar_url":"https://github.com/zillding.png","language":"JavaScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# svg-to-url\n\n[![npm](https://img.shields.io/npm/v/svg-to-url.svg)]()\n[![styled with prettier](https://img.shields.io/badge/styled_with-prettier-ff69b4.svg)](https://github.com/prettier/prettier)\n\nA node utility to convert svg to svgo optimized data url\n\nPowered by [svgo](https://github.com/svg/svgo)\n\n## Installation\n\n`npm install -g svg-to-url`\n\n## Usage\n\n### Use from command line\n\n```sh\n$ cat path/to/circle.svg\n\u003csvg xmlns=\"http://www.w3.org/2000/svg\" height=\"100\" width=\"100\"\u003e\n  \u003ccircle cx=\"50\" cy=\"50\" r=\"40\" stroke=\"black\" stroke-width=\"3\" fill=\"red\" /\u003e\n\u003c/svg\u003e\n$ svg-to-url path/to/circle.svg\ndata:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='100' width='100'%3E%3Ccircle cx='50' cy='50' r='40' stroke='%23000' stroke-width='3' fill='red'/%3E%3C/svg%3E\nCopied to clipboard!\n```\n\n### Use as a node module\n\n```js\nimport svgToUrl from \"svg-to-url\";\n\nconst result = await svgToUrl(\"path/to/circle.svg\");\nconsole.log(result);\n// data:image/svg+xml,%3Csvg xmlns='http://www.w3.org/2000/svg' height='100' width='100'%3E%3Ccircle cx='50' cy='50' r='40' stroke='%23000' stroke-width='3' fill='red'/%3E%3C/svg%3E\n```\n\nIf only the svg string processor is needed, there is another api exposed.\n\n```js\nimport { stringToUrl } from \"svg-to-url\";\n\n// optional custom svgo config: https://github.com/svg/svgo\nconst svgoConfig = {\n  plugins: [...]\n};\nconst getUrlFromSvgString = stringToUrl(svgoConfig);\n\nconst resultUrl = getUrlFromSvgString(\"\u003csvg\u003e...\u003c/svg\u003e\");\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzillding%2Fsvg-to-url","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fzillding%2Fsvg-to-url","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fzillding%2Fsvg-to-url/lists"}