# noTopLevelLiterals

Rule `biome/noTopLevelLiterals`. Require the JSON top-level value to be an array or object.

- Source: biome
- Technologies: JSON
- Kind: style
- Needs type information: no
- Autofix: no
- Reach: 2.1M weekly downloads of presets that enable it
- Trend: +151.7% last quarter
- Rank: #1547 by reach, #51 by growth

## Linters

| Linter | Rule name | Recommended | Autofix | Details | Docs |
| --- | --- | --- | --- | --- | --- |
| Biome | `style/noTopLevelLiterals` | no | no | group style, since 2.4.7 | [docs](https://biomejs.dev/linter/rules/no-top-level-literals/) |

## Code examples

### Incorrect: the rule reports this

```json
"just a string"
```

```json
42
```

```json
true
```

### Correct: the rule accepts this

```json
{
  "property": "value",
  "otherProperty": 123
}
```

```json
["element", "anotherElement"]
```

```json
{}
```

Examples from the Biome documentation.

## Enable it

### Biome: `biome.json`

```json
{
  "linter": {
    "rules": {
      "style": {
        "noTopLevelLiterals": "error"
      }
    }
  }
}
```

## Presets that enable it

| Preset | Linter | Package | Rules | Weekly downloads | Trend |
| --- | --- | --- | --- | --- | --- |
| [Ultracite for Biome](https://lintradar.dev/presets/ultracite-biome.md) | Biome | `ultracite` | 616 | 2.1M | +151.7% |

## Related rules

- [biome/noShoutyConstants](https://lintradar.dev/rules/biome/noShoutyConstants.md): Disallow constants whose string value is the same as their uppercase name.
- [biome/noUnusedTemplateLiteral](https://lintradar.dev/rules/biome/noUnusedTemplateLiteral.md): Disallow template literals if interpolation and special-character handling are not needed
- [biome/noRootType](https://lintradar.dev/rules/biome/noRootType.md): Disallow configured GraphQL root operation types.
- [biome/noUselessCatchBinding](https://lintradar.dev/rules/biome/noUselessCatchBinding.md): Disallow unused error parameters in `catch` clauses.
- [biome/noRedundantDefaultExport](https://lintradar.dev/rules/biome/noRedundantDefaultExport.md): Checks if a default export exports the same symbol as a named export.
- [biome/noValueAtRule](https://lintradar.dev/rules/biome/noValueAtRule.md): Disallow the `@value` rule in CSS Modules.

---

Web page: https://lintradar.dev/rules/biome/noTopLevelLiterals. Data from npm and the linters' documentation, collected Dec 4, 2026. Site guide for agents: https://lintradar.dev/llms.txt
