Search packages, repositories and app categories

Package detailsv0.8.2

json5

A lightweight library for encoding and decoding JSON5 with comments and trailing commas support.

AndroidiOSWebmacOSWindowsLinux
30-day downloads
13.3K
Likes
20
Pub points
150

Install package

flutter pub add json5

Package Overview

Package selection guidance compiled from public package information, community data, and project usage.

A lightweight Dart library that enables parsing and generating JSON5, a superset of JSON that supports comments, trailing commas, and other developer-friendly syntax extensions. It seamlessly integrates with Flutter apps across all major platforms, allowing developers to use more readable configuration files and data structures without sacrificing compatibility. The package is ideal for projects where human-editable data formats are preferred over strict JSON. It maintains full backward compatibility with standard JSON while adding flexibility for development workflows.

Use cases

  • Reading configuration files with comments
  • Parsing developer-friendly data formats
  • Supporting trailing commas in data definitions
  • Enabling easier debugging of structured data
  • Integrating with build scripts or asset pipelines

Key features

  • Supports JSON5 syntax including comments
  • Handles trailing commas gracefully
  • Fully compatible with standard JSON
  • Lightweight and fast performance
  • Cross-platform support (Android, iOS, Web, macOS, Windows, Linux)

Suitable for

  • Development teams using human-readable config files
  • Projects requiring flexible data input
  • Tools that generate or process structured data
  • Apps needing robust JSON parsing with extra syntax
  • Build systems or code generators

Considerations

  • Not suitable for production data interchange if strict JSON is required
  • May introduce parsing overhead compared to raw JSON
  • Requires careful validation when accepting user-provided JSON5
  • Limited ecosystem support compared to standard JSON libraries
  • Best used in development or configuration contexts, not runtime data transfer

Original README

Original README snapshot from the linked source repository. Visit the repository for the latest content.

JSON5 for Dart and Flutter

Dart CI

This Dart package is a port of JSON5, originally written in pure JavaScript.

It follows the same algorithms and specifications as the original JSON5, ensuring identical behavior.

However, Dart has different naming conventions—see the example below.

Usage

import 'package:json5/json5.dart';

void main() {
  var obj = JSON5.parse('''
      {  
        /* Comment block */  
        name: { first: "Phat" },  
        lang: ["C++", "Dart", "Kotlin"],  
        nums: [NaN, Infinity, -Infinity]  
      } // End object
  ''');

  var compact = JSON5.stringify(obj);
  print(compact);

  var pretty = JSON5.stringify(obj, space: 2);
  print(pretty);
}

References

Categories

Source repository

Projects using this package