# js2txt

> ‘js2txt’ works just like ‘JSON.stringify’, but it also supports functions. Works in both Node.js and the browser. Lightweight. No dependencies.

Latest version **1.6.14** (published 2018-06-14) · ISC license · 0 weekly downloads

## Install

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

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.6.14 |
| Published | 2018-06-14 |
| First published | 2018-04-20 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 4.7 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | Jackens |
| Maintainers | jackens |
| Keywords | js2txt, JSON.stringify |

## Links

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

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 1.6.14 (latest) — 2018-06-14
- 1.6.11 — 2018-06-11
- 1.5.20 — 2018-05-18
- 1.5.6 — 2018-05-06
- 1.4.24 — 2018-04-24
- 1.4.20 — 2018-04-20

## README

# js2txt

‘js2txt’ works just like `JSON.stringify`, but it also supports functions.
Works in both Node.js and the browser.
Lightweight. No dependencies.

## Install

## NPM

```
npm install js2txt
```

### CDN

```html
<script type="text/javascript" src="https://cdn.rawgit.com/jackens/js2txt/master/js2txt.js"></script>
```

or

```html
<script type="text/javascript" src="https://cdn.rawgit.com/jackens/js2txt/master/js2txt.min.js"></script>
```

or

```html
<script type="text/javascript" src="https://unpkg.com/js2txt/js2txt.js"></script>
```

or

```html
<script type="text/javascript" src="https://unpkg.com/js2txt/js2txt.min.js"></script>
```

## Usage

```js
var js2txt = require('js2txt')

var js = {
  array: ['a', 'r', 'r', 'a', 'y'],
  function: function (arg) {
    console.log(arg)
  },
  null: null,
  number: 42,
  object: {
    string: 'string'
  }
}
console.log(JSON.stringify(js))
console.log(js2txt(js))
```

generates the following output:

```js
{"array":["a","r","r","a","y"],"null":null,"number":42,"object":{"string":"string"}}
{array:['a','r','r','a','y'],function:function (arg) {
    console.log(arg)
  },null:null,number:42,object:{string:'string'}}
```

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