Unlike other errors, and invalid JSON error in WordPress is straightforward to understand and fix. For the unaware, this appears when WordPress can’t communicate with the web server while you work within the Block Editor. The server’s responses come in the JSON format, which explains the error.
Fixing the issue shouldn’t take more than a few minutes, and will be one of the following:
One of these will be the solution, although the hope is that you won’t need to look at all of them. We’re presenting the five solutions here from easiest to hardest, although that’s relative as you’ll likely have the skills you need to tackle each one in no time.
1. Carry Out Some Simple Steps to Diagnose the Error
Before you dig around in settings screens, you’ll want to ensure you aren’t the cause of the invalid JSON error in WordPress. However, create a full backup of your site first in case you need to reinstate your site later.
Once you have a backup in the bag, look to tick off all of the following ‘gotchas’:
If you don’t have WordPress’ debug mode active, you should also do this so you can try and catch the fault of the error. However, it’s likely going to be one of the below solutions, and they won’t take too long to resolve.
2. Check Your WordPress URLs
For the first method, you’ll want to log into WordPress and head to the Settings screen:
On the General tab, check out the two fields that read WordPress Address (URL) and Site Address (URL). In the vast majority of cases, they will be the same as the domain name for your site:
You’ll likely know if your have WordPress under a different directory that would explain a clear difference here. However, a difference WordPress doesn’t understand will trigger the invalid JSON error.
It could be that those URLs use the wrong HTTP protocol: If you have a Secure Sockets Layer (SSL) certificate, each URL should use
https://. Our advice is to check for spelling mistakes in each URL, and also check whether each ones uses the right protocol.
Once you make any fixes, save your changes and check for the error. If it still crops up, head to the next method.
3. Adjust Your WordPress Permalink Settings
While you’re in the Settings page, head to the Permalinks tab. There could be an issue under the hood with your permalink structure that could cause the invalid JSON error in WordPress.
The solution here is simple:
However, if you use a custom permalink structure, make sure there are no spelling mistakes or syntax errors with the tags you use:
Even one character out of place will cause the error, so look to fix anything you spot, save your changes, and check for further issues.
4. Take a Look at the Site Health Log for Clues
WordPress includes a handy screen to help you judge how ‘healthy’ your site is. The Site Health page is essentially a list of critical issues and recommended improvements to help with aspects of your site. For example, you can optimize performance, work on your Search Engine Optimization (SEO), and more:
If you encounter the invalid JSON error in WordPress, you may see another recommended improvement: “The REST API encountered an unexpected result”. This should give you some indication of where the JSON error lies, and from there you can investigate further.
However, if you don’t have much experience reading error logs like this, you might want to contact your host. This way, they can tell you what the issue pertains to, and whether it’s something on the server side.
5. Rebuild Your
The final method to solve the invalid JSON error in WordPress is the toughest, but still straightforward. Your
.htaccess file is a set of configurations for Apache servers.
Unlike Nginx, Apache users can handle server configurations. As such, this could cause an invalid JSON error in WordPress.
The best approach here is to rebuild the
.htaccess file itself, which is simple to do. In fact, you may have already done this when changing your permalink settings, as saving your changes here regenerates the
However, you might want to create a clean file yourself from scratch, to be sure you don’t introduce an error or keep one around.
First, you’ll want to make a backup of your old
.htaccess file. To do this, we recommend using Secure File Transfer Protocol (SFTP) to access your server and drag the
.htaccess file to your local computer. Here’s what you’ll need:
Administrative access to your server, and the login credentials. You can often find these within your hosting control panel, or in an email from your host.
.htaccess file will be in the root of your site’s primary directory, and the process is to drag it out onto your computer (and set for hidden files to show):
From here, make a duplicate on your computer, clear out the contents, and add the following:
This is a default
.htaccess file. Save it as .htaccess, then upload it to your server again. From here, check for the error.
The invalid JSON error in WordPress is simple to understand and fix, which is good if you need to continue working on your site in a hurry. Most of the solutions to this error relate to a configuration setting for your server, so you’ll poke around within WordPress’ settings screens to solve it.
In some cases, you’ll need to rebuild a
.htaccess file from scratch, but even this is friction-free. However, if you still see the error on your site, it’s a good idea to contact your host for further advice. There could be something on the server that doesn’t play nicely with your site’s configuration that they will need to look into.
Do you suffer from the invalid JSON error in WordPress, and does one of our solutions help you? Let us know in the comments section below!
This content was originally published here.