# diffx-python
Python wrapper for the `diffx` CLI tool - semantic diff for structured data.
## Installation
```bash
pip install diffx-python
```
The `diffx` binary is automatically included in the wheel - no additional downloads required! This package uses [maturin](https://github.com/PyO3/maturin) to embed the native binary directly in the Python wheel, similar to tools like `ruff`.
## 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**: Native binary embedded in platform-specific wheels
## Key Benefits
- **🚀 Zero setup**: No external downloads or binary management
- **📦 Self-contained**: Everything needed is in the wheel
- **⚡ Fast installation**: No network dependencies after `pip install`
- **🔒 Secure**: No runtime downloads from external sources
- **🌐 Offline-ready**: Works in air-gapped environments
## Development
To install in development mode:
```bash
pip install -e .[dev]
```
## Verification
Verify the installation:
```python
import diffx
print("diffx available:", diffx.is_diffx_available())
print("Version:", diffx.__version__)
```
## 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": "diff, semantic, json, yaml, toml, xml, ini, csv, structured-data, comparison, devops, ci-cd, automation, data-analysis, configuration",
"author": "kako-jun",
"author_email": null,
"download_url": null,
"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\nThe `diffx` binary is automatically included in the wheel - no additional downloads required! This package uses [maturin](https://github.com/PyO3/maturin) to embed the native binary directly in the Python wheel, similar to tools like `ruff`.\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**: Native binary embedded in platform-specific wheels\n\n## Key Benefits\n\n- **\ud83d\ude80 Zero setup**: No external downloads or binary management\n- **\ud83d\udce6 Self-contained**: Everything needed is in the wheel\n- **\u26a1 Fast installation**: No network dependencies after `pip install`\n- **\ud83d\udd12 Secure**: No runtime downloads from external sources\n- **\ud83c\udf10 Offline-ready**: Works in air-gapped environments\n\n## Development\n\nTo install in development mode:\n\n```bash\npip install -e .[dev]\n```\n\n## Verification\n\nVerify the installation:\n\n```python\nimport diffx\nprint(\"diffx available:\", diffx.is_diffx_available())\nprint(\"Version:\", diffx.__version__)\n```\n\n## License\n\nThis project is licensed under the MIT License.\n\n",
"bugtrack_url": null,
"license": "MIT",
"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.5.6",
"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": [
"diff",
" semantic",
" json",
" yaml",
" toml",
" xml",
" ini",
" csv",
" structured-data",
" comparison",
" devops",
" ci-cd",
" automation",
" data-analysis",
" configuration"
],
"urls": [
{
"comment_text": null,
"digests": {
"blake2b_256": "6ab088c10bc0a8c9c5c40d54e9d6bcaecc2b34c25f332ab878cb75ecc4388614",
"md5": "b17f77f2dda2f91652420729bcdd3710",
"sha256": "d9b6baad2472eba4cffbb294d94265e1329cdf828c3e272c78d84c9186960562"
},
"downloads": -1,
"filename": "diffx_python-0.5.6-py3-none-macosx_10_12_x86_64.whl",
"has_sig": false,
"md5_digest": "b17f77f2dda2f91652420729bcdd3710",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 1607371,
"upload_time": "2025-07-16T15:20:43",
"upload_time_iso_8601": "2025-07-16T15:20:43.865387Z",
"url": "https://files.pythonhosted.org/packages/6a/b0/88c10bc0a8c9c5c40d54e9d6bcaecc2b34c25f332ab878cb75ecc4388614/diffx_python-0.5.6-py3-none-macosx_10_12_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "affbb50a0e8b24b64b1342765ad7e4fed97e18c8bee94945eeeba0f01780dda2",
"md5": "bbe45969e752483f210ae67907f4daaa",
"sha256": "2248e832c038bf8a0618d67cd5fa931e10198feb0def6bc841e9dd92680e75a6"
},
"downloads": -1,
"filename": "diffx_python-0.5.6-py3-none-macosx_11_0_arm64.whl",
"has_sig": false,
"md5_digest": "bbe45969e752483f210ae67907f4daaa",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 1526891,
"upload_time": "2025-07-16T15:20:43",
"upload_time_iso_8601": "2025-07-16T15:20:43.496567Z",
"url": "https://files.pythonhosted.org/packages/af/fb/b50a0e8b24b64b1342765ad7e4fed97e18c8bee94945eeeba0f01780dda2/diffx_python-0.5.6-py3-none-macosx_11_0_arm64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "0c2255cee3994a649b7389f6344a3e1cf6492aecf15c6b07ef3ebff49fd4f169",
"md5": "d9327708ff7e67792a01fdeac56be642",
"sha256": "702dbdd161aa78bb03019179ee75c76f1808fceea6532c5a9d4fd50ad040898f"
},
"downloads": -1,
"filename": "diffx_python-0.5.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"has_sig": false,
"md5_digest": "d9327708ff7e67792a01fdeac56be642",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 1650814,
"upload_time": "2025-07-16T15:20:56",
"upload_time_iso_8601": "2025-07-16T15:20:56.473916Z",
"url": "https://files.pythonhosted.org/packages/0c/22/55cee3994a649b7389f6344a3e1cf6492aecf15c6b07ef3ebff49fd4f169/diffx_python-0.5.6-py3-none-manylinux_2_17_aarch64.manylinux2014_aarch64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "be47f1a787b079fdf279538ae21c6c06fad17af843f9e9773ad047f850ed85ec",
"md5": "f63ddae8827fb92c419d7a8c4cf192a5",
"sha256": "38176935d61c7faf133997fbb8367700fa87cf99a0b1954080077c4777f6426e"
},
"downloads": -1,
"filename": "diffx_python-0.5.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"has_sig": false,
"md5_digest": "f63ddae8827fb92c419d7a8c4cf192a5",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 1732938,
"upload_time": "2025-07-16T15:20:37",
"upload_time_iso_8601": "2025-07-16T15:20:37.928077Z",
"url": "https://files.pythonhosted.org/packages/be/47/f1a787b079fdf279538ae21c6c06fad17af843f9e9773ad047f850ed85ec/diffx_python-0.5.6-py3-none-manylinux_2_17_x86_64.manylinux2014_x86_64.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": null,
"digests": {
"blake2b_256": "a7411414464459f50ae37f84145c00f28d568d23c5c15b67a20d73d11e2c5dc2",
"md5": "f388dc7297d6be5e91fa9bda4b3acf6e",
"sha256": "7703283e7ab3be68826bcbd814ef1836818d5238a41a3759218ccf24b3093193"
},
"downloads": -1,
"filename": "diffx_python-0.5.6-py3-none-win_amd64.whl",
"has_sig": false,
"md5_digest": "f388dc7297d6be5e91fa9bda4b3acf6e",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.8",
"size": 1358657,
"upload_time": "2025-07-16T15:21:16",
"upload_time_iso_8601": "2025-07-16T15:21:16.280501Z",
"url": "https://files.pythonhosted.org/packages/a7/41/1414464459f50ae37f84145c00f28d568d23c5c15b67a20d73d11e2c5dc2/diffx_python-0.5.6-py3-none-win_amd64.whl",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2025-07-16 15:20:43",
"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"
}