# is-svg

> Check if a string is SVG

Latest version **6.1.0** (published 2025-07-08) · MIT license · 0 weekly downloads

## Install

```sh
npm install is-svg
pnpm add is-svg
yarn add is-svg
bun add is-svg
```

## Health

**Score 50/100 (C)** — status: stable.

Positive: has types; esm support; no vulnerabilities; high quality score.

Warnings: low downloads.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 6.1.0 |
| Published | 2025-07-08 |
| First published | 2014-04-21 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=20 |
| Dependencies | 1 |
| Unpacked size | 3.6 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 142 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | svg, vector, graphics, image, picture, type, detect, check, is, string |

## Links

- npm: https://www.npmjs.com/package/is-svg
- Repository: https://github.com/sindresorhus/is-svg
- Homepage: https://github.com/sindresorhus/is-svg#readme
- Issues: https://github.com/sindresorhus/is-svg/issues
- Funding: https://github.com/sponsors/sindresorhus
- npm.io page: https://npm.io/package/is-svg

## Dependencies (1)

- [@file-type/xml](https://npm.io/package/@file-type/xml.md) ^0.4.3

## Alternatives

- [memory-cache](https://npm.io/package/memory-cache.md) — 795.0K weekly downloads
- [@httptoolkit/proxy-agent](https://npm.io/package/@httptoolkit/proxy-agent.md) — 11.2K weekly downloads
- [express-cache-controller](https://npm.io/package/express-cache-controller.md) — 5.3K weekly downloads
- [http-cache-middleware](https://npm.io/package/http-cache-middleware.md) — 4.5K weekly downloads
- [cache2](https://npm.io/package/cache2.md) — 1.5K weekly downloads

## Recent versions

- 6.1.0 (latest) — 2025-07-08
- 6.0.0 — 2025-04-29
- 5.1.0 — 2024-08-05
- 5.0.1 — 2024-05-14
- 5.0.0 — 2023-02-28
- 4.4.0 — 2023-02-28
- 4.3.2 — 2021-11-24
- 4.3.1 — 2021-03-16
- 4.3.0 — 2021-03-16
- 4.2.2 — 2021-03-11
- 4.2.1 — 2020-01-17
- 4.2.0 — 2019-05-30
- 4.1.0 — 2019-04-05
- 4.0.0 — 2019-03-06
- 3.0.0 — 2018-02-02
- … 11 more at https://npm.io/package/is-svg/versions

## README

# is-svg

> Check if a string is [SVG](https://en.wikipedia.org/wiki/Scalable_Vector_Graphics)

## Install

```sh
npm install is-svg
```

## Usage

```js
import isSvg from 'is-svg';

isSvg('<svg xmlns="http://www.w3.org/2000/svg"><path fill="#00CD9F"/></svg>');
//=> true
```

## API

### isSvg(string, options?)

#### options

Type: `object`

##### validate

Type: `boolean`\
Default: `true`

Whether to validate the SVG as proper XML.

Turning this off can improve performance significantly.

---
_Source: https://npm.io/package/is-svg · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
