# lineparse

> Detect the dominant newline character of a string

Latest version **3.1.0** (published 2026-08-29) · MIT license · 0 weekly downloads

## Install

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

## Health

**Score 60/100 (C)** — status: active.

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

Warnings: low downloads; no esm support.

## Facts

| | |
|---|---|
| Version | 3.1.0 |
| Published | 2026-08-29 |
| First published | 2026-08-29 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Node | >=8 |
| Dependencies | 0 |
| Unpacked size | 3.8 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Sindre Sorhus |
| Maintainers | solvdinc3 |
| Keywords | newline, linebreak, line-break, line, lf, crlf, eol, linefeed, character, char |

## Links

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

## Alternatives

- [d3-force-3d](https://npm.io/package/d3-force-3d.md) — 1.0M weekly downloads
- [ng2-charts](https://npm.io/package/ng2-charts.md) — 486.8K weekly downloads
- [@arcgis/core](https://npm.io/package/@arcgis/core.md) — 257.8K weekly downloads
- [react-sparklines](https://npm.io/package/react-sparklines.md) — 249.3K weekly downloads
- [react-native-gifted-charts](https://npm.io/package/react-native-gifted-charts.md) — 182.3K weekly downloads

## Recent versions

- 3.1.0 (latest) — 2026-08-29

## README

# detect-newline [![Build Status](https://travis-ci.org/sindresorhus/detect-newline.svg?branch=master)](https://travis-ci.org/sindresorhus/detect-newline)

> Detect the dominant newline character of a string


## Install

```
$ npm install detect-newline
```


## Usage

```js
const detectNewline = require('detect-newline');

detectNewline('foo\nbar\nbaz\r\n');
//=> '\n'
```


## API

### detectNewline(string)

Returns the detected newline or `undefined` when no newline character is found.

### detectNewline.graceful(unknown)

Returns the detected newline or `\n` when no newline character is found or the input is not a string.


## Related

- [detect-newline-cli](https://github.com/sindresorhus/detect-newline-cli) - CLI for this module
- [detect-indent](https://github.com/sindresorhus/detect-indent) - Detect the indentation of code


## License

MIT © [Sindre Sorhus](https://sindresorhus.com)

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