{"id":16347744,"url":"https://github.com/privatenumber/svg-browser-export","last_synced_at":"2025-10-09T20:44:56.068Z","repository":{"id":62354871,"uuid":"404486017","full_name":"privatenumber/svg-browser-export","owner":"privatenumber","description":"Export SVG to PNG, JPEG, or WEBP in the browser","archived":false,"fork":false,"pushed_at":"2021-09-09T03:44:43.000Z","size":66,"stargazers_count":23,"open_issues_count":0,"forks_count":2,"subscribers_count":2,"default_branch":"develop","last_synced_at":"2025-03-17T18:53:54.588Z","etag":null,"topics":["browser","convert","export","frontend","jpeg","png","save","svg","webp"],"latest_commit_sha":null,"homepage":"","language":"TypeScript","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/privatenumber.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-09-08T20:27:06.000Z","updated_at":"2024-05-28T18:59:27.000Z","dependencies_parsed_at":"2022-10-31T10:47:47.538Z","dependency_job_id":null,"html_url":"https://github.com/privatenumber/svg-browser-export","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fsvg-browser-export","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fsvg-browser-export/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fsvg-browser-export/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/privatenumber%2Fsvg-browser-export/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/privatenumber","download_url":"https://codeload.github.com/privatenumber/svg-browser-export/tar.gz/refs/heads/develop","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":244717078,"owners_count":20498279,"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":["browser","convert","export","frontend","jpeg","png","save","svg","webp"],"created_at":"2024-10-11T00:45:35.874Z","updated_at":"2025-10-09T20:44:51.031Z","avatar_url":"https://github.com/privatenumber.png","language":"TypeScript","funding_links":[],"categories":[],"sub_categories":[],"readme":"# svg-browser-export \u003ca href=\"https://npm.im/svg-browser-export\"\u003e\u003cimg src=\"https://badgen.net/npm/v/svg-browser-export\"\u003e\u003c/a\u003e \u003ca href=\"https://npm.im/svg-browser-export\"\u003e\u003cimg src=\"https://badgen.net/npm/dm/svg-browser-export\"\u003e\u003c/a\u003e \u003ca href=\"https://bundlephobia.com/result?p=svg-browser-export\"\u003e\u003cimg src=\"https://badgen.net/bundlephobia/minzip/svg-browser-export\"\u003e\u003c/a\u003e\n\nExport SVG to PNG, JPEG, or WEBP in the browser\n\n\u003csub\u003eSupport this project by ⭐️ starring and sharing it. [Follow me](https://github.com/privatenumber) to see what other cool projects I'm working on! ❤️\u003c/sub\u003e\n\n## 🚀 Install\n\n```bash\nnpm i svg-browser-export\n```\n\n## 🚦 Quick usage\n\n```ts\nimport { exportSvg } from 'svg-browser-export'\n\nconst svgString = '\u003csvg\u003e...\u003c/svg\u003e'\n\nconst exportedFileUrl = await exportSvg(svgString, 'png')\n// =\u003e data:image/png;base64,....\n```\n\n\n## 👩‍🏫 Examples\n\n### Exporting an SVG on the page\nSelect the DOM element (eg. using [querySelector](https://developer.mozilla.org/en-US/docs/Web/API/Document/querySelector)) and access `.innerHTML` for the SVG string.\n```ts\nconst svgElement = document.querySelector('.svg-selector')\n\nconst exportedFileUrl = await exportSvg(svgElement.innerHTML, 'png')\n```\n\n### Downloading the exported file\nUse it with [downloadjs](https://www.npmjs.com/package/downloadjs) to automatically download the exported asset.\n\n```ts\nimport { exportSvg } from 'svg-browser-export'\nimport download from 'downloadjs'\n\n...\n\nconst exportedFileUrl = await exportSvg(svgString, 'png')\n\ndownload(exportedFileUrl, 'anyFileName.png')\n\n```\n\n## ⚙️ API\n\n### exportSvg(svgString, exportFormat, scale)\n\nReturns a promise that resolves to the exported file as a Base64 data URL.\n\n#### svgString\nType: `string`\n\nThe SVG string to convert.\n\n#### exportFormat\nType: `'png' | 'jpeg' | 'bmp' | 'ico' | 'webp'`\n\nThe format to export the SVG to.\n\n\n#### scale\nType: `number`\n\nOptional\n\nIf you want to scale the SVG. For example, passing in `2` would double the dimensions of the SVG.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivatenumber%2Fsvg-browser-export","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fprivatenumber%2Fsvg-browser-export","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fprivatenumber%2Fsvg-browser-export/lists"}