If you have two JSON files that should be identical but are hard to compare due to the unordered nature of JSON, this VSCode extension can help by sorting then comparing them making it easier to focus on real content differences.
This extension sorts JSON files before comparison to make it easier to spot the differences in JSON files.
- Sort JSON objects by their keys.
- Compare two JSON files and highlight the differences.
Here’s a quick demo: two sample JSON files are compared using the extension, demonstrating that only one key-value pair differs. The comparison is then displayed in VSCode’s diff viewer, which can make it difficult to fully grasp the differences between unordered JSON files.
- Visual Studio Code version 1.93.0 or higher.
You can install the vscode extension from here.
- Run the "Sort and Compare JSON Files" command from the Command Palette (
Ctrl+Shift+P
orCmd+Shift+P
on macOS). - The extension will prompt you for the first and second file
- The extension will sort the JSON objects and display the differences.
- Clone the repository:
git clone https://github.com/pharzan/json-sort-compare-vscode.git
- Navigate to the project directory:
cd json-sort-and-compare
- Install the dependencies:
npm install
- Compile the TypeScript code:
npm run compile
- Open the project in Visual Studio Code.
- Press
F5
to open a new VS Code window with the extension loaded.
- Compile the TypeScript code:
npm run compile
- Run the tests:
npm test
- Fork the repository.
- Create a new branch:
git checkout -b feature/your-feature-name
- Make your changes and commit them:
git commit -m 'Add some feature'
- Push to the branch:
git push origin feature/your-feature-name
- Open a pull request.
This project is licensed under the MIT License. See the LICENSE file for details.