# oneline

> Write nice template literals with newlines, but format as a single-line string

Latest version **2.0.0** (published 2025-03-16) · MIT license · 0 weekly downloads

## Install

```sh
npm install oneline
pnpm add oneline
yarn add oneline
bun add oneline
```

## Health

**Score 40/100 (D)** — status: maintenance-mode.

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

Warnings: low downloads.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 2.0.0 |
| Published | 2025-03-16 |
| First published | 2015-12-30 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | ESM + CommonJS |
| Node | >=18.0.0 |
| Dependencies | 0 |
| Unpacked size | 4.5 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Espen Hovlandsdal |
| Maintainers | rexxars |
| Keywords | template-literal, template-string, tagged, string, multiline |

## Links

- npm: https://www.npmjs.com/package/oneline
- Repository: https://github.com/rexxars/oneline
- Homepage: https://github.com/rexxars/oneline#readme
- Issues: https://github.com/rexxars/oneline/issues
- npm.io page: https://npm.io/package/oneline

## Alternatives

- [@mce/gif](https://npm.io/package/@mce/gif.md) — 2.6K weekly downloads
- [cleanse](https://npm.io/package/cleanse.md) — 173 weekly downloads
- [str](https://npm.io/package/str.md) — 127 weekly downloads
- [naming](https://npm.io/package/naming.md) — 95 weekly downloads
- [tap-telco-api](https://npm.io/package/tap-telco-api.md) — 19 weekly downloads

## Recent versions

- 2.0.0 (latest) — 2025-03-16
- 0.0.0 (next) — 2015-12-30
- 1.0.4 — 2025-03-16
- 1.0.3 — 2019-04-09
- 1.0.2 — 2019-03-05
- 1.0.1 — 2019-03-05
- 1.0.0 — 2018-10-31

## README

# oneline

Write nice template literals with newlines, but format as a single-line string.
Trims leading/trailing whitespace and replaces all newlines and subsequent whitespace with a single space.

[![npm version](https://img.shields.io/npm/v/oneline.svg?style=flat-square)](https://www.npmjs.com/package/oneline)[![npm bundle size](https://img.shields.io/bundlephobia/minzip/oneline?style=flat-square)](https://bundlephobia.com/result?p=oneline)[![npm weekly downloads](https://img.shields.io/npm/dw/oneline.svg?style=flat-square)](https://www.npmjs.com/package/oneline)

## Installing

```
npm install --save oneline
```

## Basic usage

```js
import {oneline} from 'oneline'

const url = 'https://docs.npmjs.com/'
const message = oneline`
  It's a fine day to write a long, verbose string.
  It could contain all sorts of expressions, let's for instance
  inject a URL, say to the NPM docs: ${url}. In the end, this will
  all result in a single line of text.
`

console.log(message)
// It's a fine day to write a long, verbose string. It could contain all sorts of expressions, let's for instance inject a URL, say to the NPM docs: https://docs.npmjs.com/. In the end, this will all result in a single line of text.
```

## Thanks to...

Thanks [Hal Henke](https://github.com/halhenke) for donating the package name! <3

## License

MIT © [Espen Hovlandsdal](https://espen.codes/)

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