PHPackages                             nette/neon - PHPackages - PHPackages  [Skip to content](#main-content)[PHPackages](/)[Directory](/)[Categories](/categories)[Trending](/trending)[Leaderboard](/leaderboard)[Changelog](/changelog)[Analyze](/analyze)[Collections](/collections)[Log in](/login)[Sign up](/register)

1. [Directory](/)
2. /
3. [Parsing &amp; Serialization](/categories/parsing)
4. /
5. nette/neon

ActiveLibrary[Parsing &amp; Serialization](/categories/parsing)

nette/neon
==========

🍸 Nette NEON: encodes and decodes NEON file format.

v3.4.7(4mo ago)93562.1M—4.5%36[1 issues](https://github.com/nette/neon/issues)[1 PRs](https://github.com/nette/neon/pulls)20BSD-3-ClausePHPPHP 8.0 - 8.5CI passing

Since May 11Pushed 1w ago46 watchersCompare

[ Source](https://github.com/nette/neon)[ Packagist](https://packagist.org/packages/nette/neon)[ Docs](https://neon.nette.org)[ RSS](/packages/nette-neon/feed)WikiDiscussions master Synced 1mo ago

READMEChangelog (10)Dependencies (3)Versions (47)Used By (20)

[![NEON](https://private-user-images.githubusercontent.com/194960/331236740-9d3c809d-0a60-4ff0-a54a-bbb25273a8a8.jpg?jwt=eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3NzkxNzAyOTAsIm5iZiI6MTc3OTE2OTk5MCwicGF0aCI6Ii8xOTQ5NjAvMzMxMjM2NzQwLTlkM2M4MDlkLTBhNjAtNGZmMC1hNTRhLWJiYjI1MjczYThhOC5qcGc_WC1BbXotQWxnb3JpdGhtPUFXUzQtSE1BQy1TSEEyNTYmWC1BbXotQ3JlZGVudGlhbD1BS0lBVkNPRFlMU0E1M1BRSzRaQSUyRjIwMjYwNTE5JTJGdXMtZWFzdC0xJTJGczMlMkZhd3M0X3JlcXVlc3QmWC1BbXotRGF0ZT0yMDI2MDUxOVQwNTUzMTBaJlgtQW16LUV4cGlyZXM9MzAwJlgtQW16LVNpZ25hdHVyZT0yYTczYjUxMGIwMjdlZDI0N2ZlZWQ5MzdkOGZmMGVmYmRjNmU1N2RhMGZkZGFmZmRlODBlYmRlNDM4OWFmNWNkJlgtQW16LVNpZ25lZEhlYWRlcnM9aG9zdCZyZXNwb25zZS1jb250ZW50LXR5cGU9aW1hZ2UlMkZqcGVnIn0.S8nS08k2N0SSz_tyQa3ND7vm8kmHV2A3IhLAa8FiZZQ)](https://neon.nette.org)

[![Downloads this Month](https://camo.githubusercontent.com/ca5228a6c402f7800664033f6b64967a9eb3c084e582a3f5964c9b427e16e862/68747470733a2f2f696d672e736869656c64732e696f2f7061636b61676973742f646d2f6e657474652f6e656f6e2e737667)](https://packagist.org/packages/nette/neon)[![Tests](https://github.com/nette/neon/workflows/Tests/badge.svg?branch=master)](https://github.com/nette/neon/actions)[![Coverage Status](https://camo.githubusercontent.com/4949b3568a12bd7edf33011ebbf2c9a9e37c7c885d2ab052bca2148e23fef307/68747470733a2f2f636f766572616c6c732e696f2f7265706f732f6769746875622f6e657474652f6e656f6e2f62616467652e7376673f6272616e63683d6d6173746572)](https://coveralls.io/github/nette/neon?branch=master)[![Latest Stable Version](https://camo.githubusercontent.com/679880ea631f620e39be8e342291a239eded3aae23006b14a3056c6e5b43cc72/68747470733a2f2f706f7365722e707567782e6f72672f6e657474652f6e656f6e2f762f737461626c65)](https://github.com/nette/neon/releases)[![License](https://camo.githubusercontent.com/fa7d5fcf2c84b580327af52da95dd751703af65f079dc3c5a0081beac0789718/68747470733a2f2f696d672e736869656c64732e696f2f62616467652f6c6963656e73652d4e65772532304253442d626c75652e737667)](https://github.com/nette/neon/blob/master/license.md)

Introduction
============

[](#introduction)

NEON is a human-readable structured data format. In Nette, it is used for configuration files. It is also used for structured data such as settings, language translations, etc. [Try it on the sandbox](https://fiddle.nette.org/neon/).

NEON stands for *Nette Object Notation*. It is less complex and ungainly than XML or JSON, but provides similar capabilities. It is very similar to YAML. The main advantage is that NEON has so-called [entities](#entities), thanks to which the configuration of DI services is so sexy. And allows tabs for indentation.

NEON is built from the ground up to be simple to use.

[Support Neon](https://github.com/sponsors/dg)
----------------------------------------------

[](#support-neon)

Do you like NEON? Are you looking forward to the new features?

[![Buy me a coffee](https://camo.githubusercontent.com/afa7c20ccaac10ac4f1f51669bafb212856b932e0c8b276cb290336cf08624b8/68747470733a2f2f66696c65732e6e657474652e6f72672f69636f6e732f646f6e6174696f6e2d332e737667)](https://github.com/sponsors/dg)

Thank you!

Usage
=====

[](#usage)

Install via Composer:

```
composer require nette/neon

```

It requires PHP version 8.3 up to 8.5. Documentation can be found on the [website](https://doc.nette.org/neon).

`Neon::encode()` returns `$value` converted to NEON. As the second parameter `$blockMode` you can pass true, which will create multiline output. The third parameter `$indentation` specifies the characters used for indentation (default is tab).

```
use Nette\Neon\Neon;

$neon = Neon::encode($value); // Returns $value converted to NEON
$neon = Neon::encode($value, true); // Returns $value converted to multiline NEON
```

`Neon::decode()` converts given NEON to PHP value:

```
$value = Neon::decode('hello: world'); // Returns an array ['hello' => 'world']
```

`Neon::decodeFile()` converts given NEON file to PHP value:

```
$value = Neon::decodeFile('config.neon');
```

All methods throw `Nette\Neon\Exception` on error.

Integration
===========

[](#integration)

- NetBeans (has built-in support)
- PhpStorm ([plugin](https://plugins.jetbrains.com/plugin/28338-neon))
- Visual Studio Code ([plugin](https://marketplace.visualstudio.com/items?itemName=Kasik96.latte))
- Sublime Text 3 ([plugin](https://github.com/FilipStryk/Nette-Latte-Neon-for-Sublime-Text-3))
- Sublime Text 2 ([plugin](https://github.com/Michal-Mikolas/Nette-package-for-Sublime-Text-2))
- [NEON for PHP](https://doc.nette.org/neon)
- [NEON for JavaScript](https://github.com/matej21/neon-js)
- [NEON for Python](https://github.com/paveldedik/neon-py).

You can check for syntax errors in Neon files using the `neon-lint` console command:

```
vendor/bin/neon-lint
```

Syntax
======

[](#syntax)

A file written in NEON usually consists of a sequence or mapping.

Mappings
--------

[](#mappings)

Mapping is a set of key-value pairs, in PHP it would be called an associative array. Each pair is written as `key: value`, a space after `:` is required. The value can be anything: string, number, boolean, null, sequence, or other mapping.

```
street: 742 Evergreen Terrace
city: Springfield
country: USA
```

In PHP, the same structure would be written as:

```
[ // PHP
	'street' => '742 Evergreen Terrace',
	'city' => 'Springfield',
	'country' => 'USA',
]
```

This notation is called a block notation because all items are on a separate line and have the same indentation (none in this case). NEON also supports inline representation for mapping, which is enclosed in brackets, indentation plays no role, and the separator of each element is either a comma or a newline:

```
{street: 742 Evergreen Terrace, city: Springfield, country: USA}
```

This is the same written on multiple lines (indentation does not matter):

```
{
	street: 742 Evergreen Terrace
		city: Springfield, country: USA
}
```

Alternatively, `=` can be used instead of `: `, both in block and inline notation:

```
{street=742 Evergreen Terrace, city=Springfield, country=USA}
```

Sequences
---------

[](#sequences)

Sequences are indexed arrays in PHP. They are written as lines starting with the hyphen `-` followed by a space. Again, the value can be anything: string, number, boolean, null, sequence, or other mapping.

```
- Cat
- Dog
- Goldfish
```

In PHP, the same structure would be written as:

```
[ // PHP
	'Cat',
	'Dog',
	'Goldfish',
]
```

This notation is called a block notation because all items are on a separate line and have the same indentation (none in this case). NEON also supports inline representation for sequences, which is enclosed in brackets, indentation plays no role, and the separator of each element is either a comma or a newline:

```
[Cat, Dog, Goldfish]
```

This is the same written on multiple lines (indentation does not matter):

```
[
	Cat, Dog
		Goldfish
]
```

Hyphens cannot be used in an inline representation.

Combination
-----------

[](#combination)

Values of mappings and sequences may be other mappings and sequences. The level of indentation plays a major role. In the following example, the hyphen used to indicate sequence items has a greater indent than the `pets` key, so the items become the value of the first line:

```
pets:
   - Cat
   - Dog
cars:
   - Volvo
   - Skoda
```

In PHP, the same structure would be written as:

```
[ // PHP
	'pets' => [
		'Cat',
		'Dog',
	],
	'cars' => [
		'Volvo',
		'Skoda',
	],
]
```

It is possible to combine block and inline notation:

```
pets: [Cat, Dog]
cars: [
	Volvo,
	Skoda,
]
```

Block notation can no longer be used inside an inline notation, this does not work:

```
item: [
	pets:
	 - Cat     # THIS IS NOT POSSIBLE!!!
	 - Dog
]
```

In the previous case, we wrote a mapping whose elements were sequences. Now, let's try it the other way around and create a sequence containing mappings:

```
-
	name: John
	age: 35
-
	name: Peter
	age: 28
```

It's not necessary for the bullet points to be on separate lines; they can also be placed in this manner:

```
- name: John
  age: 35
- name: Peter
  age: 28
```

It's up to you whether you align the keys in a column using spaces or a tab.

Because PHP uses the same structure for mapping and sequences, that is, arrays, both can be merged. The indentation is the same this time:

```
- Cat
street: 742 Evergreen Terrace
- Goldfish
```

In PHP, the same structure would be written as:

```
[ // PHP
	'Cat',
	'street' => '742 Evergreen Terrace',
	'Goldfish',
]
```

Strings
-------

[](#strings)

Strings in NEON can be enclosed in single or double quotes. But as you can see, they can also be without quotes.

```
- A unquoted string in NEON
- 'A singled-quoted string in NEON'
- "A double-quoted string in NEON"
```

If the string contains characters `# " ' , : = - [ ] { } ( )` that can be confused with NEON syntax, it must be enclosed in quotation marks. We recommend using single quotes because they do not use escaping. If you need to enclose a quotation mark in such a string, double it:

```
'A single quote '' inside a single-quoted string'
```

Double quotes allow you to use escape sequences to write special characters using backslashes `\`. All escape sequences as in the JSON format are supported, plus `\_`, which is an non-breaking space, ie `\u00A0`.

```
- "\t \n \r \f \b \" \\ \/ \_"
- "\u00A9"
```

There are other cases where you need to enclose strings in quotation marks:

- they begin or end with spaces
- look like numbers, booleans, or null
- NEON would understand them as [dates](#dates)

Multiline Strings
-----------------

[](#multiline-strings)

A multiline string begins and ends with a triple quotation mark on separate lines. The indent of the first line is ignored for all lines:

```
'''
	first line
		second line
	third line
	'''
```

In PHP we would write the same as:

```
"first line\n\tsecond line\nthird line" // PHP
```

Escaping sequences only work for strings enclosed in double quotes instead of apostrophes:

```
"""
	Copyright \u00A9
"""
```

Numbers
-------

[](#numbers)

NEON understands numbers written in so-called scientific notation and also numbers in binary, octal and hexadecimal:

```
- 12         # an integer
- 12.3       # a float
- +1.2e-34   # an exponential number

- 0b11010    # binary number
- 0o666      # octal number
- 0x7A       # hexa number
```

Nulls
-----

[](#nulls)

Null can be expressed in NEON by using `null` or by not specifying a value. Variants with a capital first or all uppercase letters are also allowed.

```
a: null
b:
```

Booleans
--------

[](#booleans)

Boolean values are expressed in NEON using `true` / `false` or `yes` / `no`. Variants with a capital first or all uppercase letters are also allowed.

```
[true, TRUE, True, false, yes, no]
```

Dates
-----

[](#dates)

NEON uses the following formats to express data and automatically converts them to `DateTimeImmutable` objects:

```
- 2016-06-03                  # date
- 2016-06-03 19:00:00         # date & time
- 2016-06-03 19:00:00.1234    # date & microtime
- 2016-06-03 19:00:00 +0200   # date & time & timezone
- 2016-06-03 19:00:00 +02:00  # date & time & timezone
```

Entities
--------

[](#entities)

An entity is a structure that resembles a function call:

```
Column(type: int, nulls: yes)
```

In PHP, it is parsed as an object [Nette\\Neon\\Entity](https://api.nette.org/3.4/Nette/Neon/Entity.html):

```
// PHP
new Nette\Neon\Entity('Column', ['type' => 'int', 'nulls' => true])
```

Entities can also be chained:

```
Column(type: int, nulls: yes) Field(id: 1)
```

Which is parsed in PHP as follows:

```
// PHP
new Nette\Neon\Entity(Nette\Neon\Neon::Chain, [
	new Nette\Neon\Entity('Column', ['type' => 'int', 'nulls' => true]),
	new Nette\Neon\Entity('Field', ['id' => 1]),
])
```

Inside the parentheses, the rules for inline notation used for mapping and sequences apply, so it can be divided into several lines and it is not necessary to add commas:

```
Column(
	type: int
	nulls: yes
)
```

Comments
--------

[](#comments)

Comments start with `#` and all of the following characters on the right are ignored:

```
# this line will be ignored by the interpreter
street: 742 Evergreen Terrace
city: Springfield  # this is ignored too
country: USA
```

NEON Versus JSON
================

[](#neon-versus-json)

JSON is a subset of NEON. Each JSON can therefore be parsed as NEON:

```
{
"php": {
	"date.timezone": "Europe\/Prague",
	"zlib.output_compression": true
},
"database": {
	"driver": "mysql",
	"username": "root",
	"password": "beruska92"
},
"users": [
	"Dave", "Kryten", "Rimmer"
]
}
```

What if we could omit quotes?

```
{
php: {
	date.timezone: Europe/Prague,
	zlib.output_compression: true
},
database: {
	driver: mysql,
	username: root,
	password: beruska92
},
users: [
	Dave, Kryten, Rimmer
]
}
```

How about braces and commas?

```
php:
	date.timezone: Europe/Prague
	zlib.output_compression: true

database:
	driver: mysql
	username: root
	password: beruska92

users: [
	Dave, Kryten, Rimmer
]
```

Are bullets more legible?

```
php:
	date.timezone: Europe/Prague
	zlib.output_compression: true

database:
	driver: mysql
	username: root
	password: beruska92

users:
	- Dave
	- Kryten
	- Rimmer
```

How about comments?

```
# my web application config

php:
	date.timezone: Europe/Prague
	zlib.output_compression: true  # use gzip

database:
	driver: mysql
	username: root
	password: beruska92

users:
	- Dave
	- Kryten
	- Rimmer
```

You found NEON syntax!

If you like NEON, **[please make a donation now](https://github.com/sponsors/dg)**. Thank you!

###  Health Score

79

—

ExcellentBetter than 100% of packages

Maintenance88

Actively maintained with recent releases

Popularity74

Solid adoption and visibility

Community49

Growing community involvement

Maturity93

Battle-tested with a long release history

 Bus Factor1

Top contributor holds 92.5% of commits — single point of failure

How is this calculated?**Maintenance (25%)** — Last commit recency, latest release date, and issue-to-star ratio. Uses a 2-year decay window.

**Popularity (30%)** — Total and monthly downloads, GitHub stars, and forks. Logarithmic scaling prevents top-heavy scores.

**Community (15%)** — Contributors, dependents, forks, watchers, and maintainers. Measures real ecosystem engagement.

**Maturity (30%)** — Project age, version count, PHP version support, and release stability.

###  Release Activity

Cadence

Every ~98 days

Recently: every ~130 days

Total

45

Last Release

71d ago

Major Versions

v2.4.3 → v3.0.02019-02-05

v2.4.x-dev → v3.0.x-dev2021-01-25

PHP version history (12 changes)v2.2.0PHP &gt;=5.3.1

v2.4.0PHP &gt;=5.6.0

v3.0.0PHP &gt;=7.0

v3.1.0PHP &gt;=7.1

v2.4.x-devPHP &gt;=5.6 &lt;8.1

v3.0.x-devPHP &gt;=7.0 &lt;8.1

v3.1.x-devPHP &gt;=7.1 &lt;8.1

v3.4.0PHP &gt;=8.0 &lt;8.3

v3.4.1PHP 8.0 - 8.3

v3.4.4PHP 8.0 - 8.4

v3.3.4PHP 7.1 - 8.4

v3.4.5PHP 8.0 - 8.5

### Community

Maintainers

![](https://www.gravatar.com/avatar/17f266513a3ca97500ec3d85d562b9279c7a6346358fe2b8d90390ece717a027?d=identicon)[david@grudl.com](/maintainers/david@grudl.com)

---

Top Contributors

[![dg](https://avatars.githubusercontent.com/u/194960?v=4)](https://github.com/dg "dg (332 commits)")[![JanTvrdik](https://avatars.githubusercontent.com/u/175109?v=4)](https://github.com/JanTvrdik "JanTvrdik (6 commits)")[![matej21](https://avatars.githubusercontent.com/u/1276059?v=4)](https://github.com/matej21 "matej21 (5 commits)")[![xsuchy09](https://avatars.githubusercontent.com/u/1107359?v=4)](https://github.com/xsuchy09 "xsuchy09 (2 commits)")[![f3l1x](https://avatars.githubusercontent.com/u/538058?v=4)](https://github.com/f3l1x "f3l1x (2 commits)")[![fprochazka](https://avatars.githubusercontent.com/u/158625?v=4)](https://github.com/fprochazka "fprochazka (2 commits)")[![janbarasek](https://avatars.githubusercontent.com/u/4738758?v=4)](https://github.com/janbarasek "janbarasek (1 commits)")[![janedbal](https://avatars.githubusercontent.com/u/1993453?v=4)](https://github.com/janedbal "janedbal (1 commits)")[![clxmstaab](https://avatars.githubusercontent.com/u/47448731?v=4)](https://github.com/clxmstaab "clxmstaab (1 commits)")[![ccampos](https://avatars.githubusercontent.com/u/951688?v=4)](https://github.com/ccampos "ccampos (1 commits)")[![ondrejmirtes](https://avatars.githubusercontent.com/u/104888?v=4)](https://github.com/ondrejmirtes "ondrejmirtes (1 commits)")[![pepakriz](https://avatars.githubusercontent.com/u/383294?v=4)](https://github.com/pepakriz "pepakriz (1 commits)")[![sallyx](https://avatars.githubusercontent.com/u/4263901?v=4)](https://github.com/sallyx "sallyx (1 commits)")[![vjirovsky](https://avatars.githubusercontent.com/u/2659294?v=4)](https://github.com/vjirovsky "vjirovsky (1 commits)")[![vrana](https://avatars.githubusercontent.com/u/117453?v=4)](https://github.com/vrana "vrana (1 commits)")[![andares](https://avatars.githubusercontent.com/u/7556505?v=4)](https://github.com/andares "andares (1 commits)")

---

Tags

languageneonneon-syntaxnettenette-frameworkparsingphpyamlnetteexportyamlimportneon

### Embed Badge

![Health badge](/badges/nette-neon/health.svg)

```
[![Health](https://phpackages.com/badges/nette-neon/health.svg)](https://phpackages.com/packages/nette-neon)
```

###  Alternatives

[jms/metadata

Class/method/property metadata management in PHP

1.8k152.8M88](/packages/jms-metadata)[mustangostang/spyc

A simple YAML loader/dumper class for PHP

73440.3M172](/packages/mustangostang-spyc)[hassankhan/config

Lightweight configuration file loader that supports PHP, INI, XML, JSON, and YAML files

97513.5M170](/packages/hassankhan-config)[spatie/yaml-front-matter

A to the point yaml front matter parser

3411.8M68](/packages/spatie-yaml-front-matter)[pragmarx/yaml

Load your Laravel config files using yaml

1152.8M29](/packages/pragmarx-yaml)[dragon-code/codestyler

A tool to automatically fix Coding Style Standards issues by The Dragon Code.

291.8M16](/packages/dragon-code-codestyler)

PHPackages © 2026

[Directory](/)[Categories](/categories)[Trending](/trending)[Changelog](/changelog)[Analyze](/analyze)
