yaml_edit
2.2.4, released 9 months ago by tools.dart.dev
YAML manipulation library preserving comments and whitespace
WASM-ready
What it does
Provides a YamlEditor class to parse, modify, and serialize YAML while keeping comments and formatting intact. It supports updates, inserts, deletions, and conversion from JSON.
AI-written summary of version 2.2.4, based on the package's README and metadata. Report an inaccuracy
Use it when
- You need to edit YAML files programmatically while keeping comments
- You want to convert JSON to YAML with preserved structure
- You require fine-grained control over YAML nodes
Skip it when
- You only need simple YAML parsing without comment preservation
- You need a code generation tool for YAML schemas
Strengths
- Preserves comments and whitespace
- Supports complex updates via path-based API
- Handles JSON-to-YAML conversion
Weaknesses
- No support for custom tags
- Map keys always added in flow style
- Limited to YAML manipulation only
Setup
- Kind
- Pure Dart
- Effort
- Low
- Code generation
- No
- Direct dependencies
- 4
import 'package:yaml_edit/yaml_edit.dart';
final editor = YamlEditor('{YAML: YAML}');
editor.update(['YAML'], "YAML Ain't Markup Language");
print(editor);Alternatives
Packages that do the same job and could replace yaml_edit.
- pubspec_manager
Type-safe API to read, modify, and write pubspec.yaml while preserving comments.
78Compare
Works with
Packages commonly used together with yaml_edit: ones it builds on, ones built on it, and its own family.
- yamlyaml_edit depends on itA Dart library for parsing YAML documents into Dart data structures.
- source_spanyaml_edit depends on itStandard representation for source code locations, spans, and human-friendly error messages.
- analyzerSame familyPerforms static analysis of Dart code for tool integration and embedding.
- dart_styleSame familyProvides an API and CLI to format Dart source code automatically.
- pubspec_parseSame familyParse pubspec.yaml files with a type‑safe API and detailed error reporting.
- coverageSame familyCollects, manipulates, and formats code coverage data in Dart
- test_apiSame familyThe user facing API for structuring Dart tests and checking expectations.
- source_mapsSame familyA Dart library to parse, build, and manipulate source map v3 files.