# Lines to JSON Array

> Turns each non-empty line, without the spaces around it, into a string in a JSON array

Version: 1.0.0 · By Deck

- Install in Deck: deck://install-plugin?id=lines-to-json-array&url=https%3A%2F%2Fgithub.com%2Fyuzeguitarist%2Fdeck-plugins%2Freleases%2Fdownload%2Fplugins%2Flines-to-json-array-1.0.0.zip
- Download .zip: https://github.com/yuzeguitarist/deck-plugins/releases/download/plugins/lines-to-json-array-1.0.0.zip
- View on GitHub: https://github.com/yuzeguitarist/deck-plugins/tree/main/plugins/lines-to-json-array

Or install with Terminal: 

```sh
mkdir -p ~/.deck/scripts/lines-to-json-array && curl -fsSL https://github.com/yuzeguitarist/deck-plugins/releases/download/plugins/lines-to-json-array-1.0.0.zip | tar -xf - -C ~/.deck/scripts/lines-to-json-array
```

## Script

```js
// Turns each non-empty line, without the spaces around it, into a string in a JSON array.
function transform(input) {
  const lines = String(input ?? "").split(/\r\n|\r|\n/).map((line) => line.trim()).filter((line) => line !== "");
  return JSON.stringify(lines, null, 2);
}
```

---

- HTML: https://deckclip.app/plugins/lines-to-json-array
- 中文: https://deckclip.app/zh-cn/plugins/lines-to-json-array.md

© 2026 Yuze Pan
