Skip to main content

English | 日本語

yaqpy — YAML and more, Query editor in Python

License: MIT Python 3.13+ GitHub release

yaqpy — YAML and more, Query editor in Python

A lightweight tool to query, update and convert YAML, JSON and more with expressions, from the command line or from Python.

  • It follows the expression language of the popular CLI tool mikefarah/yq (Go, v4.53.6)
  • It is re-implemented with nothing but the Python standard library
  • The name stands for YAML And more, Query editor in PYthon
$ yaqpy '.server.port' config.yaml
8080
$ yaqpy -i '.server.port = 9090' config.yaml     # comments and key order are kept

Features

  • Keeps your formatting: comments, key order, anchors (& / *) and the way numbers and quotes were written (0x1F, 1.50, 'yes') survive an update
  • No dependencies: all it needs is Python 3.13 or later. The GUI is an optional extra (Flet); the web version adds flet-web
  • Four ways to use it: the yaqpy command, the Python library (import yaqpy), a desktop GUI (yaqpy-gui) and the same GUI in a web browser (yaqpy-web)
  • Formats: YAML, JSON, XML, CSV / TSV, TOML, properties and TOON (a token-saving format for LLMs), both in and out. TOML comments are not kept, so -i on TOML is refused by default
  • Compatible with yq: 1,091 test scenarios of the Go version are run as compatibility tests (1,047 of the 1,051 comparable ones match). Every operator works except load and friends, eval, envsubst, system and error
  • Beyond yq (not in the Go version):
    • the input format is detected from the content when the file extension does not tell it
    • yaqpy --schema data.yaml prints a JSON Schema (Draft 2020-12) of the data, as JSON or YAML
    • yaqpy --recipe openai-to-gemini request.json converts request bodies between OpenAI, Gemini and Anthropic, and reports what was dropped, added, or does not fit the target schema (results go to stdout; files are written only with --apply --out-dir; no API is called)
    • yaqpy describes itself for people and AI: --print-spec (the operators that work and those that do not), --example, --guide-prompt (a prompt that lets an AI write yaqpy expressions) and --skill-md (a Claude Code skill)
  • Safe defaults: as a library, operators that read files or environment variables or run commands are all off. The CLI, like the Go version, allows environment variables and file reads (commands stay off). The web version always turns them off

Installation

Python 3.13 or later is required.

pip install yaqpy                   # the yaqpy command and the library (no dependencies)
pip install "yaqpy[gui]"            # + the desktop GUI (adds Flet)
pip install "yaqpy[web]"            # + the GUI in a web browser (adds Flet and flet-web)

With uv:

uv tool install yaqpy               # install the yaqpy command
uv tool install "yaqpy[gui,web]"    # ... with what yaqpy-gui and yaqpy-web need
uvx yaqpy '.server.port' config.yaml   # run it once without installing
uv add yaqpy                        # use it as a library in a uv project

From GitHub Releases (for example, a version that is not on PyPI): pick a version on Releases and replace 0.6.0 / v0.6.0 below with it.

pip install "yaqpy[gui] @ https://github.com/sgtao/yaqpy/releases/download/v0.6.0/yaqpy-0.6.0-py3-none-any.whl"
pip install "yaqpy[gui] @ git+https://github.com/sgtao/yaqpy@v0.6.0"

To work on the source, see DEVELOPMENT.md (Japanese).

Quick start

Take this config.yaml:

# server settings
server:
  port: 8080 # dev
  hosts: [a, b]
items:
  - {name: pen, price: 120}
  - {name: book, price: 980}

Command line

yaqpy '.server.port' config.yaml                              # read -> 8080
yaqpy '.items[] | select(.price > 500) | .name' config.yaml   # filter -> book
yaqpy -i '.server.port = 9090' config.yaml                    # update (comments and key order are kept)
yaqpy -o json '.server' config.yaml                           # convert (yaml / json / xml / csv / tsv / toml / props / toon)

Python library

import yaqpy

yaqpy.evaluate(".server.port", "server:\n  port: 8080\n")        # '8080\n'
yaqpy.query(".items[] | select(.price > 500)", {"items": [{"price": 1}, {"price": 900}]})   # [{'price': 900}]
yaqpy.update(".server.port = 9090", {"server": {"port": 8080}})  # {'server': {'port': 9090}}

GUI

yaqpy-gui                # desktop window (or: yaqpy --gui)
yaqpy-web                # the same screens in your browser at http://127.0.0.1:8550/ (or: yaqpy --web)
yaqpy-web --port 9000    # another port; see yaqpy-web --help for the options

The web version listens on this PC only by default and has no authentication. Files are uploaded from the browser and results come back as downloads.

Documentation

The detailed guides are written in Japanese.

Contents File
This README in Japanese README.ja.md
The command, each format, JSON Schema output, recipes, the library, the operators, and the differences from Go yq USAGE.ja.md
The GUI (desktop and web) USAGE-GUI.ja.md
For developers (setup, design, tests, repository layout) DEVELOPMENT.md
Changes in each version (features, known limitations) CHANGELOG.md

yaqpy --help, yaqpy-gui --help and yaqpy-web --help are in English.

License

MIT License

The design and the test scenarios draw on Go yq (MIT); see NOTICE.


🤖 Built with Claude Code

Release files for yaqpy 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for yaqpy 0.6.0
File Size Uploaded
yaqpy-0.6.0.tar.gz 236.0 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for yaqpy 0.6.0
File Interpreter ABI Platform
yaqpy-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 548.1 kB

Release files / yaqpy-0.6.0.tar.gz

Download URL yaqpy-0.6.0.tar.gz
Size 236.0 kB
Tags Source
SHA-256 checksum
How to use checksums
1cf3f7d7d17517b6e27a3e45bb5be9f9ff94cd38851406f469393ddedae4813f
BLAKE2b-256 checksum
How to use checksums
161f5a294c67804b0eba422ab4d2be1293f99b7406c76bfd7594344687fdf451
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release files / yaqpy-0.6.0-py3-none-any.whl

Download URL yaqpy-0.6.0-py3-none-any.whl
Size 312.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0be87d0d16c3b70825408efd6a18b4b90298d8279f9e0a331779a5fd2e880bcb
BLAKE2b-256 checksum
How to use checksums
4137039b6383b260818d0efc77c2e276101d90a37146bd4f9af24b3fa51938a0
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via uv/0.11.17 {"installer":{"name":"uv","version":"0.11.17","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":null,"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":null}

Release history Release notifications | RSS feed

0.7.1

2 release files

0.7.0

2 release files

This release

0.6.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page