# stringify-attributes

> Turn an object into a string of HTML attributes

Latest version **5.0.0** (published 2026-06-28) · MIT license · 58.6K weekly downloads

## Install

```sh
npm install stringify-attributes
pnpm add stringify-attributes
yarn add stringify-attributes
bun add stringify-attributes
```

## Health

**Score 75/100 (B)** — status: active.

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

## Facts

| | |
|---|---|
| Version | 5.0.0 |
| Published | 2026-06-28 |
| First published | 2017-06-17 |
| Weekly downloads | 58.6K |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM |
| Node | >=22 |
| Dependencies | 0 |
| Unpacked size | 4.1 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 52 |
| Author | Sindre Sorhus |
| Maintainers | sindresorhus |
| Keywords | html, attributes, stringify, element, tag, props, object, convert, transform |

## Links

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

## Alternatives

- [@tsparticles/shape-image](https://npm.io/package/@tsparticles/shape-image.md) — 303.7K weekly downloads
- [@tsparticles/shape-line](https://npm.io/package/@tsparticles/shape-line.md) — 233.7K weekly downloads
- [mobile-drag-drop](https://npm.io/package/mobile-drag-drop.md) — 46.3K weekly downloads
- [@comunica/actor-rdf-parse-html](https://npm.io/package/@comunica/actor-rdf-parse-html.md) — 29.2K weekly downloads
- [fetch-base64](https://npm.io/package/fetch-base64.md) — 11.9K weekly downloads

## Recent versions

- 5.0.0 (latest) — 2026-06-28
- 4.0.0 — 2023-03-30
- 3.0.0 — 2021-04-16
- 2.0.0 — 2019-04-28
- 1.0.0 — 2017-06-17

## README

# stringify-attributes

> Turn an object into a string of HTML attributes

## Install

```sh
npm install stringify-attributes
```

## Usage

```js
import stringifyAttributes from 'stringify-attributes';

stringifyAttributes({
	unicorn: '🦄',
	rainbow: true,
	number: 1,
	multiple: [
		'a',
		'b'
	]
});
//=> ' unicorn="🦄" rainbow number="1" multiple="a b"'
```

Note that the string is prepended with a space when there are attributes to simplify using it in a HTML tag.

## Related

- [create-html-element](https://github.com/sindresorhus/create-html-element) - Create a HTML element string

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