# diffx-python
Python wrapper for the `diffx` CLI tool - semantic diff for structured data.
## Installation
```bash
pip install diffx-python
```
This will automatically download the appropriate `diffx` binary for your system from GitHub Releases.
## Usage
```python
import diffx
# Compare two JSON files
result = diffx.diff('file1.json', 'file2.json')
print(result)
# Get structured output as JSON
json_result = diffx.diff(
'config1.yaml',
'config2.yaml',
diffx.DiffOptions(format='yaml', output='json')
)
for diff_item in json_result:
if diff_item.added:
print(f"Added: {diff_item.added}")
elif diff_item.modified:
print(f"Modified: {diff_item.modified}")
# Compare directory trees
dir_result = diffx.diff(
'dir1/',
'dir2/',
diffx.DiffOptions(recursive=True, path='config')
)
# Compare strings directly
json1 = '{"name": "Alice", "age": 30}'
json2 = '{"name": "Alice", "age": 31}'
string_result = diffx.diff_string(
json1, json2, 'json',
diffx.DiffOptions(output='json')
)
```
## Features
- **Multiple formats**: JSON, YAML, TOML, XML, INI, CSV
- **Smart diffing**: Understands structure, not just text
- **Flexible output**: CLI, JSON, YAML, unified diff formats
- **Advanced options**:
- Regex-based key filtering
- Floating-point tolerance
- Array element identification
- Path-based filtering
- **Cross-platform**: Automatically downloads the right binary
## Development
To install in development mode with uv:
```bash
uv venv
source .venv/bin/activate
uv pip install -e .[dev]
```
## Manual Binary Installation
If automatic download fails:
```bash
diffx-download-binary
```
## License
This project is licensed under the MIT License.
Raw data
{
"_id": null,
"home_page": null,
"name": "diffx-python",
"maintainer": null,
"docs_url": null,
"requires_python": ">=3.8",
"maintainer_email": null,
"keywords": "automation, ci-cd, comparison, configuration, csv, data-analysis, devops, diff, ini, json, semantic, structured-data, toml, xml, yaml",
"author": "kako-jun",
"author_email": null,
"download_url": "https://files.pythonhosted.org/packages/f4/e6/64b3e0f2f301dee662074611a4a06bcbff2c2883e620fb0c9b4394d1c21d/diffx_python-0.4.4.tar.gz",
"platform": null,
"description": "# diffx-python\n\nPython wrapper for the `diffx` CLI tool - semantic diff for structured data.\n\n## Installation\n\n```bash\npip install diffx-python\n```\n\nThis will automatically download the appropriate `diffx` binary for your system from GitHub Releases.\n\n## Usage\n\n```python\nimport diffx\n\n# Compare two JSON files\nresult = diffx.diff('file1.json', 'file2.json')\nprint(result)\n\n# Get structured output as JSON\njson_result = diffx.diff(\n 'config1.yaml', \n 'config2.yaml',\n diffx.DiffOptions(format='yaml', output='json')\n)\n\nfor diff_item in json_result:\n if diff_item.added:\n print(f\"Added: {diff_item.added}\")\n elif diff_item.modified:\n print(f\"Modified: {diff_item.modified}\")\n\n# Compare directory trees\ndir_result = diffx.diff(\n 'dir1/', \n 'dir2/',\n diffx.DiffOptions(recursive=True, path='config')\n)\n\n# Compare strings directly\njson1 = '{\"name\": \"Alice\", \"age\": 30}'\njson2 = '{\"name\": \"Alice\", \"age\": 31}'\nstring_result = diffx.diff_string(\n json1, json2, 'json',\n diffx.DiffOptions(output='json')\n)\n```\n\n\n## Features\n\n- **Multiple formats**: JSON, YAML, TOML, XML, INI, CSV\n- **Smart diffing**: Understands structure, not just text\n- **Flexible output**: CLI, JSON, YAML, unified diff formats\n- **Advanced options**: \n - Regex-based key filtering\n - Floating-point tolerance\n - Array element identification\n - Path-based filtering\n- **Cross-platform**: Automatically downloads the right binary\n\n## Development\n\nTo install in development mode with uv:\n\n```bash\nuv venv\nsource .venv/bin/activate\nuv pip install -e .[dev]\n```\n\n## Manual Binary Installation\n\nIf automatic download fails:\n\n```bash\ndiffx-download-binary\n```\n\n## License\n\nThis project is licensed under the MIT License.\n",
"bugtrack_url": null,
"license": null,
"summary": "Python wrapper for diffx - semantic diffing of JSON, YAML, TOML, XML, INI, and CSV files. Focuses on structural meaning rather than formatting.",
"version": "0.4.4",
"project_urls": {
"Documentation": "https://github.com/kako-jun/diffx/tree/main/docs",
"Homepage": "https://github.com/kako-jun/diffx",
"Issues": "https://github.com/kako-jun/diffx/issues",
"Repository": "https://github.com/kako-jun/diffx"
},
"split_keywords": [
"automation",
" ci-cd",
" comparison",
" configuration",
" csv",
" data-analysis",
" devops",
" diff",
" ini",
" json",
" semantic",
" structured-data",
" toml",
" xml",
" yaml"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "8dbb5a15d67eb92b5ec31088032513754a1bd68301f3c0e47248f580a99c357d",
"md5": "f369e53fe95cd9ce53743de096013b95",
"sha256": "645aebf817a43f2a809e52e5627deb2d59739ee4f548e5ed6436930bade087a9"
},
"downloads": -1,
"filename": "diffx_python-0.4.4-py3-none-any.whl",
"has_sig": false,
"md5_digest": "f369e53fe95cd9ce53743de096013b95",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 7726,
"upload_time": "2025-07-12T02:15:07",
"upload_time_iso_8601": "2025-07-12T02:15:07.299735Z",
"url": "https://files.pythonhosted.org/packages/8d/bb/5a15d67eb92b5ec31088032513754a1bd68301f3c0e47248f580a99c357d/diffx_python-0.4.4-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "f4e664b3e0f2f301dee662074611a4a06bcbff2c2883e620fb0c9b4394d1c21d",
"md5": "2a5c01741348bbc0c3c295e50fedb4f5",
"sha256": "e723e8dadcfb607327fa0ae6b0ea2ed8aa618405b10c57d50f77e4f06b1fb334"
},
"downloads": -1,
"filename": "diffx_python-0.4.4.tar.gz",
"has_sig": false,
"md5_digest": "2a5c01741348bbc0c3c295e50fedb4f5",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.8",
"size": 6670,
"upload_time": "2025-07-12T02:15:08",
"upload_time_iso_8601": "2025-07-12T02:15:08.301896Z",
"url": "https://files.pythonhosted.org/packages/f4/e6/64b3e0f2f301dee662074611a4a06bcbff2c2883e620fb0c9b4394d1c21d/diffx_python-0.4.4.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-12 02:15:08",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "kako-jun",
"github_project": "diffx",
"travis_ci": false,
"coveralls": false,
"github_actions": true,
"lcname": "diffx-python"
}