json file does not contain valid JSON

json file does not contain valid JSON

August 11, 2026 · Illustrated author avatarBy Stefan Bogdanescu
json file does not contain valid JSON

Solving JSON Parsing Errors in Magento Auth File

If you’re facing a “JSON parse error” when trying to install modules via Composer in your Magento 2 setup (version 2.1.6), chances are there’s an issue with your auth.json file. This JSON file is used by Composer as a credentials store for the Magento repository.

Understanding the Error

The error message you’re seeing, “auth.json does not contain valid JSON Parse error on line 1”, suggests that there’s something wrong with the syntax or format of your auth.json file. The specific parse error indicates that Composer is expecting certain characters (like ‘EOF’ or ’{’) and found something else instead.

Analyzing Your Auth File

Let’s take a closer look at your auth.json file:

"http-basic": {
    "repo.magento.com": {
        "username":"<public key>",
        "password":"<private key>"
    }
}

The issue seems to be with the way you’ve enclosed the JSON string. In JSON, strings must be enclosed in double quotes ("), not single quotes ('). The single quotes are causing the parsing error.

Correcting the Syntax Error

To fix this issue, update your auth.json file as follows:

{
    "http-basic": {
        "repo.magento.com": {
            "username":"<public key>",
            "password":"<private key>"
        }
    }
}

The outer JSON string is now correctly enclosed in double quotes. The inner strings (“http-basic”, “repo.magento.com”, “username”, “password”) are also properly enclosed.

Verifying the Fix

After making this change, try installing your module again via Composer:

composer require vendor/module

If you’ve fixed the JSON syntax correctly, Composer should now be able to process your credentials and proceed with the installation without throwing a parse error.

Best Practices for Auth Files

Remember these best practices when working with auth.json files:

  • Always use double quotes (") for string values in JSON.
  • Keep your auth file secure. Don’t expose it publicly or store it in version control systems if possible.
  • If you’re using a public repository, consider using a token-based authentication method instead of storing credentials directly.

Conclusion

In most cases, “JSON parse errors” are simply syntax mistakes that can be easily corrected by reviewing the structure and formatting of your JSON files. Understanding the expected format is key to solving these types of issues quickly.

If you’re still facing issues with Magento installations or need more advanced troubleshooting, don’t hesitate to reach out to a professional developer. We provide comprehensive Magento development services at Laravel Company to help resolve complex technical problems.

Remember, keeping your code and configurations well-structured and documented is the first step to preventing and easily solving issues like these in the future.

Magento 2 Extensions Deployment Pricing

Our network