# balena-config-json

> Balena config.json manipulation utilities

Latest version **4.2.7** (published 2025-04-02) · Apache-2.0 license · 0 weekly downloads

## Install

```sh
npm install balena-config-json
pnpm add balena-config-json
yarn add balena-config-json
bun add balena-config-json
```

## Health

**Score 45/100 (D)** — status: stable.

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

Warnings: low downloads; no esm support.

Negative: stale.

## Facts

| | |
|---|---|
| Version | 4.2.7 |
| Published | 2025-04-02 |
| First published | 2018-10-29 |
| Weekly downloads | 0 |
| License | Apache-2.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 22.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 2 |
| Author | Balena Inc. |
| Maintainers | balena.io |
| Keywords | balena, config, json, device, image |

## Links

- npm: https://www.npmjs.com/package/balena-config-json
- Repository: https://github.com/balena-io-modules/balena-config-json
- Issues: https://github.com/balena-io-modules/balena-config-json/issues
- npm.io page: https://npm.io/package/balena-config-json

## Dependencies (3)

- [file-disk](https://npm.io/package/file-disk.md) ^8.0.1
- [partitioninfo](https://npm.io/package/partitioninfo.md) ^6.0.2
- [balena-image-fs](https://npm.io/package/balena-image-fs.md) ^7.5.0

## 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

- 4.2.7 (latest) — 2025-04-02
- 4.2.8-build-renovate-major-7-jsdoc-to-markdown-126e7fba00d368fed6d4ac0566cc8e058439636d-1 (build-renovate-major-7-jsdoc-to-markdown) — 2025-04-02
- 4.2.8-build-renovate-major-8-jsdoc-to-markdown-db27e2863a5047206ce971cf46b228f64ade0cfd-1 (build-renovate-major-8-jsdoc-to-markdown) — 2025-04-02
- 4.2.8-build-renovate-major-9-jsdoc-to-markdown-2579ca62c7aad29b112d7c2ad4cc223f17471854-1 (build-renovate-major-9-jsdoc-to-markdown) — 2025-04-02
- 4.2.7-build-getBootPartition-log-fix-d91290d9c4b502652c50a34482ff68448eb0a4c2-1 (build-getBootPartition-log-fix) — 2025-04-02
- 4.2.6-build-update-balena-image-fs-9d5a44175e7f46f2f3963d794d48d3de8f49300f-1 (build-update-balena-image-fs) — 2025-03-26
- 4.2.5-build-renovate-major-7--balenalint-b91ecbe2d39426e039adf94e04c569908c3837dd-1 (build-renovate-major-7--balenalint) — 2025-03-26
- 4.2.5-build-renovate-major-9--balenalint-7230173f938341c20db773293286d079045332b6-1 (build-renovate-major-9--balenalint) — 2025-03-26
- 4.2.5-build-renovate-major-8--balenalint-93f9b19268bcf9dd68cc5f82f581807c765ef24a-1 (build-renovate-major-8--balenalint) — 2025-03-26
- 4.2.5-build-balena-lint-v9-0ff1aa1ed8803b622948214493e1f9ec88cfe910-1 (build-balena-lint-v9) — 2025-03-26
- 4.2.3-build-bump-typescript-to-5-8-2-5280b87287d62968b43f8921ea8c6f63502dbff7-1 (build-bump-typescript-to-5-8-2) — 2025-03-26
- 4.2.3-build-renovate-major-5-chai-7fe83ffc781eb66ac3535749f7fdf56d458eb959-1 (build-renovate-major-5-chai) — 2025-03-19
- 4.2.2-build-partition-by-fs-label-38cc709214b80cea8816e81769b7fd55c2b17dc9-1 (build-partition-by-fs-label) — 2025-02-20
- 4.2.1-build-kyle-flowzone-3129af229b7dc125553c7ad50391712bd343034d-1 (build-kyle-flowzone) — 2025-02-20
- 4.2.7-build-renovate-major-7-jsdoc-to-markdown-66cb05f072e7559682c45ee8c76fe4a016e34690-1 — 2025-04-01
- … 44 more at https://npm.io/package/balena-config-json/versions

## README

balena-config-json
-----------------

[![npm version](https://badge.fury.io/js/balena-config-json.svg)](http://badge.fury.io/js/balena-config-json)
[![dependencies](https://david-dm.org/balena-io-modules/balena-config-json.png)](https://david-dm.org/balena-io-modules/balena-config-json.png)
[![Build Status](https://travis-ci.org/balena-io-modules/balena-config-json.svg?branch=master)](https://travis-ci.org/balena-io-modules/balena-config-json)
[![Build status](https://ci.appveyor.com/api/projects/status/ndm6cfnvotbsyaqx/branch/master?svg=true)](https://ci.appveyor.com/project/balena-io-modules/balena-config-json/branch/master)

Balena config.json manipulation utilities.

Role
----

The intention of this module is to provide low level utilities to read and write `config.json` from balena devices.

**THIS MODULE IS LOW LEVEL AND IS NOT MEANT TO BE USED BY END USERS DIRECTLY**.

Installation
------------

Install `balena-config-json` by running:

```sh
$ npm install --save balena-config-json
```

Documentation
-------------


* [config](#module_config)
    * [~read(image, _type)](#module_config..read) ⇒ <code>Promise</code>
    * [~write(image, _type, config)](#module_config..write) ⇒ <code>Promise</code>

<a name="module_config..read"></a>

### config~read(image, _type) ⇒ <code>Promise</code>
**Kind**: inner method of [<code>config</code>](#module_config)  
**Summary**: Read a config.json from an image  
**Access**: public  
**Fulfil**: <code>Object</code> - config.json  

| Param | Type | Description |
| --- | --- | --- |
| image | <code>String</code> | image or drive path |
| _type | <code>String</code> | ignored (device type, no longer required) |

**Example**  
```js
config.read('/dev/disk2', 'raspberry-pi').then (config) ->
	console.log(config)
```
<a name="module_config..write"></a>

### config~write(image, _type, config) ⇒ <code>Promise</code>
**Kind**: inner method of [<code>config</code>](#module_config)  
**Summary**: Write a config.json to an image  
**Access**: public  

| Param | Type | Description |
| --- | --- | --- |
| image | <code>String</code> | image or drive path |
| _type | <code>String</code> | ignored (device type, no longer required) |
| config | <code>Object</code> | config.json |

**Example**  
```js
config.write '/dev/disk2', 'raspberry-pi',
	username: 'foobar'
.then ->
	console.log('Done!')
```

Support
-------

If you're having any problem, please [raise an issue](https://github.com/balena-io-modules/balena-config-json/issues/new) on GitHub and the balena team will be happy to help.

Tests
-----

Run the test suite by doing:

```sh
$ gulp test
```

Contribute
----------

- Issue Tracker: [github.com/balena-io-modules/balena-config-json/issues](https://github.com/balena-io-modules/balena-config-json/issues)
- Source Code: [github.com/balena-io-modules/balena-config-json](https://github.com/balena-io-modules/balena-config-json)

Before submitting a PR, please make sure that you include tests, and that `npm run lint` runs without any warning:

```sh
$ gulp lint
```

License
-------

The project is licensed under the Apache 2.0 license.

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