{"id":13396156,"url":"https://github.com/kislyuk/yq","last_synced_at":"2025-05-14T22:03:06.972Z","repository":{"id":37752476,"uuid":"78888191","full_name":"kislyuk/yq","owner":"kislyuk","description":"Command-line YAML, XML, TOML processor - jq wrapper for YAML/XML/TOML documents","archived":false,"fork":false,"pushed_at":"2025-01-01T18:03:12.000Z","size":355,"stargazers_count":2754,"open_issues_count":32,"forks_count":84,"subscribers_count":32,"default_branch":"main","last_synced_at":"2025-05-07T21:12:14.631Z","etag":null,"topics":["cli","command-line","jq","json","xml","yaml","yml"],"latest_commit_sha":null,"homepage":"https://kislyuk.github.io/yq/","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/kislyuk.png","metadata":{"files":{"readme":"README.rst","changelog":"Changes.rst","contributing":null,"funding":".github/FUNDING.yml","license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":"SECURITY.md","support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null},"funding":{"github":["kislyuk"]}},"created_at":"2017-01-13T21:30:19.000Z","updated_at":"2025-05-06T12:35:44.000Z","dependencies_parsed_at":"2023-12-10T18:27:45.605Z","dependency_job_id":"de780055-4294-4e3f-8b75-d0b55de3adf6","html_url":"https://github.com/kislyuk/yq","commit_stats":{"total_commits":241,"total_committers":15,"mean_commits":"16.066666666666666","dds":"0.17842323651452285","last_synced_commit":"6065f397e3c8d47482d124c4adf0b276985d7077"},"previous_names":[],"tags_count":51,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kislyuk%2Fyq","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kislyuk%2Fyq/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kislyuk%2Fyq/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/kislyuk%2Fyq/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/kislyuk","download_url":"https://codeload.github.com/kislyuk/yq/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254235685,"owners_count":22036962,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cli","command-line","jq","json","xml","yaml","yml"],"created_at":"2024-07-30T18:00:41.459Z","updated_at":"2025-05-14T22:03:06.912Z","avatar_url":"https://github.com/kislyuk.png","language":"Python","funding_links":["https://github.com/sponsors/kislyuk"],"categories":["Python","Data Manipulation","Command Line","cli","Awesome Tools","YAML/XML/TOML","JSON / YAML / CSV"],"sub_categories":["Processors","Like jq","Terminal Tools","Open USP Tsukubai","CLI Tools"],"readme":"yq: Command-line YAML/XML/TOML processor - jq wrapper for YAML, XML, TOML documents\n===================================================================================\n\nInstallation\n------------\n::\n\n    pip install yq\n\nBefore using ``yq``, you also have to install its dependency, ``jq``. See the `jq installation instructions\n\u003chttps://stedolan.github.io/jq/download/\u003e`_ for details and directions specific to your platform.\n\nOn macOS, ``yq`` is also available on `Homebrew \u003chttps://brew.sh/\u003e`_: use ``brew install python-yq``.\n\nSynopsis\n--------\n\n``yq`` takes YAML input, converts it to JSON, and pipes it to `jq \u003chttps://stedolan.github.io/jq/\u003e`_::\n\n    cat input.yml | yq .foo.bar\n\nLike in ``jq``, you can also specify input filename(s) as arguments::\n\n    yq .foo.bar input.yml\n\nBy default, no conversion of ``jq`` output is done. Use the ``--yaml-output``/``-y`` option to convert it back into YAML::\n\n    cat input.yml | yq -y .foo.bar\n\nMapping key order is preserved. By default, custom `YAML tags \u003chttp://www.yaml.org/spec/1.2/spec.html#id2764295\u003e`_ and\n`styles \u003chttps://yaml.org/spec/current.html#id2509255\u003e`_ in the input are ignored. Use the ``--yaml-roundtrip``/``-Y``\noption to preserve YAML tags and styles by representing them as extra items in their enclosing mappings and sequences\nwhile in JSON::\n\n    yq -Y .foo.bar input.yml\n\nyq can be called as a module if needed. With ``-y/-Y``, files can be edited in place like with ``sed -i``::\n\n    python -m yq -Y --indentless --in-place '.[\"current-context\"] = \"staging-cluster\"' ~/.kube/config\n\nUse the ``--width``/``-w`` option to pass the line wrap width for string literals. Use\n``--explicit-start``/``--explicit-end`` to emit YAML start/end markers even when processing a single document. All other\ncommand line arguments are forwarded to ``jq``. ``yq`` forwards the exit code ``jq`` produced, unless there was an error\nin YAML parsing, in which case the exit code is 1. See the `jq manual \u003chttps://stedolan.github.io/jq/manual/\u003e`_ for more\ndetails on ``jq`` features and options.\n\nBecause YAML treats JSON as a dialect of YAML, you can use yq to convert JSON to YAML: ``yq -y . \u003c in.json \u003e out.yml``.\n\nPreserving tags and styles using the ``-Y`` (``--yaml-roundtrip``) option\n~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n\nThe ``-Y`` option helps preserve custom `string styles \u003chttps://yaml-multiline.info/\u003e`_ and\n`tags \u003chttps://camel.readthedocs.io/en/latest/yamlref.html#tags\u003e`_ in your document. For example, consider the following\ndocument (an `AWS CloudFormation \u003chttps://aws.amazon.com/cloudformation/\u003e`_ template fragment)::\n\n    Resources:\n      ElasticLoadBalancer:\n        Type: 'AWS::ElasticLoadBalancing::LoadBalancer'\n        Properties:\n          AvailabilityZones: !GetAZs ''\n          Instances:\n            - !Ref Ec2Instance1\n            - !Ref Ec2Instance2\n          Description: \u003e-\n            Load balancer for Big Important Service.\n\n            Good thing it's managed by this template.\n\nPassing this document through ``yq -y .Resources.ElasticLoadBalancer`` will drop custom tags, such as ``!Ref``,\nand styles, such as the `folded \u003chttps://yaml-multiline.info/\u003e`_ style of the ``Description`` field::\n\n    Type: AWS::ElasticLoadBalancing::LoadBalancer\n    Properties:\n      AvailabilityZones: ''\n      Instances:\n        - Ec2Instance1\n        - Ec2Instance2\n      Description: 'Load balancer for Big Important Service.\n\n        Good thing it''s managed by this template.'\n\nBy contrast, passing it through ``yq -Y .Resources.ElasticLoadBalancer`` will preserve tags and styles::\n\n    Type: 'AWS::ElasticLoadBalancing::LoadBalancer'\n    Properties:\n      AvailabilityZones: !GetAZs ''\n      Instances:\n        - !Ref 'Ec2Instance1'\n        - !Ref 'Ec2Instance2'\n      Description: \u003e-\n        Load balancer for Big Important Service.\n\n        Good thing it's managed by this template.\n\nTo accomplish this in ``-Y`` mode, yq carries extra metadata (mapping pairs and sequence values) in the JSON\nrepresentation of your document for any custom tags or styles that it finds. When converting the JSON back into YAML, it\nparses this metadata, re-applies the tags and styles, and discards the extra pairs and values.\n\n.. warning ::\n\n The ``-Y`` option is incompatible with jq filters that do not expect the extra information injected into the document\n to preserve the YAML formatting. For example, a jq filter that counts entries in the Instances array will come up with\n 4 entries instead of 2. A filter that expects all array entries to be mappings may break due to the presence of string\n metadata keys. Check your jq filter for compatibility/semantic validity when using the ``-Y`` option.\n\nyq does not support passing YAML comments into the JSON representation used by jq, or roundtripping such comments.\n\nXML support\n-----------\n``yq`` also supports XML. The ``yq`` package installs an executable, ``xq``, which\n`transcodes XML to JSON \u003chttps://www.xml.com/pub/a/2006/05/31/converting-between-xml-and-json.html\u003e`_ using\n`xmltodict \u003chttps://github.com/martinblech/xmltodict\u003e`_ and pipes it to ``jq``. Roundtrip transcoding is available with\nthe ``xq --xml-output``/``xq -x`` option. Multiple XML documents can be passed in separate files/streams as\n``xq a.xml b.xml``. Use ``--xml-item-depth`` to descend into large documents, streaming their contents without loading\nthe full doc into memory (for example, stream a `Wikipedia database dump \u003chttps://dumps.wikimedia.org\u003e`_ with\n``cat enwiki-*.xml.bz2 | bunzip2 | xq . --xml-item-depth=2``). Entity expansion and DTD resolution is disabled to avoid\nXML parsing vulnerabilities. Use ``python -m yq.xq`` if you want to ensure a specific Python runtime.\n\nTOML support\n------------\n``yq`` supports `TOML \u003chttps://toml.io/\u003e`_ as well. The ``yq`` package installs an executable, ``tomlq``, which uses the\n`tomlkit library \u003chttps://github.com/sdispater/tomlkit\u003e`_ to transcode TOML to JSON, then pipes it to ``jq``. Roundtrip\ntranscoding is available with the ``tomlq --toml-output``/``tomlq -t`` option. Use ``python -m yq.tomlq`` if you want to\nensure a specific Python runtime.\n\n.. admonition:: Compatibility note\n\n This package's release series available on PyPI begins with version 2.0.0. Versions of ``yq`` prior to 2.0.0 are\n distributed by https://github.com/abesto/yq and are not related to this package. No guarantees of compatibility are\n made between abesto/yq and kislyuk/yq. This package follows the `Semantic Versioning 2.0.0 \u003chttp://semver.org/\u003e`_\n standard. To ensure proper operation, declare dependency version ranges according to SemVer.\n\nAuthors\n-------\n* Andrey Kislyuk\n\nLinks\n-----\n* `Project home page (GitHub) \u003chttps://github.com/kislyuk/yq\u003e`_\n* `Documentation \u003chttps://kislyuk.github.io/yq/\u003e`_\n* `Package distribution (PyPI) \u003chttps://pypi.python.org/pypi/yq\u003e`_\n* `Change log \u003chttps://github.com/kislyuk/yq/blob/master/Changes.rst\u003e`_\n* `jq \u003chttps://stedolan.github.io/jq/\u003e`_ - the command-line JSON processor utility powering ``yq``\n\nBugs\n~~~~\nPlease report bugs, issues, feature requests, etc. on `GitHub \u003chttps://github.com/kislyuk/yq/issues\u003e`_.\n\nLicense\n-------\nLicensed under the terms of the `Apache License, Version 2.0 \u003chttp://www.apache.org/licenses/LICENSE-2.0\u003e`_.\n\n.. image:: https://github.com/kislyuk/yq/workflows/Python%20package/badge.svg\n        :target: https://github.com/kislyuk/yq/actions\n.. image:: https://codecov.io/github/kislyuk/yq/coverage.svg?branch=master\n        :target: https://codecov.io/github/kislyuk/yq?branch=master\n.. image:: https://img.shields.io/pypi/v/yq.svg\n        :target: https://pypi.python.org/pypi/yq\n.. image:: https://img.shields.io/pypi/l/yq.svg\n        :target: https://pypi.python.org/pypi/yq\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkislyuk%2Fyq","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fkislyuk%2Fyq","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fkislyuk%2Fyq/lists"}