• Categories
    • Tutorials
    • Beginners Guide
    • WordPress News
    • WordPress Security
    • Best WordPress Plugins
    • WordPress Themes
    • Product Reviews
    • WP Tips & Tricks
  • Guides
    • Start a Blog
    • Make a Website
    • WordPress Hosting
  • WordPress Hosting
    • A2 Hosting
    • HostGator
    • Bluehost
    • Cloudways
  • Managed Hosting
    • WPEngine
    • Rocket.net
    • WPX
    • Kinsta
  • Coupons
    • WPEngine
    • Flywheel
    • Cloudways
    • A2 Hosting
    • WPX Hosting
WordPress Tutorials

How to Fix an Invalid JSON Error in WordPress

Last Updated on: June 8, 2022 Tom Rankin Leave a Comment

How to Fix an Invalid JSON Error in WordPress

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:

  • Figuring out whether something simple is the cause of the error.
  • Checking your WordPress URLs and altering them if necessary.
  • Adjusting your permalink settings, or at least rebuilding them.
  • Looking at the Site Health page within WordPress for clues on how to proceed.
  • Rebuilding your .htaccess file.

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’:

  • Switch to a default theme, in case your primary one has a fault.
  • Turn off your Web Application Firewall (WAF), if you use one. It could be that you’ll disable your security plugin as a whole on a temporary basis.
  • Speaking of which, it’s a good idea to deactivate and reactive your plugins to see if one is the cause of the invalid JSON error in WordPress. This is a typical troubleshooting step within the platform, and can sometimes spotlight an issue with a rogue plugin.
  • Try using the Classic Editor, to see if you can still achieve what you need without seeing the error. However, you shouldn’t consider this a permanent fix, more scraping the rust off of a faulty engine.

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:

The WordPress 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:

The fields for the WordPress Address URL and the Site Address URL.

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.

Wordress' Permalink Settings screen.

The solution here is simple:

  • Choose a permalink type. Unless you use a Custom Structure, stick with the current option on this page.
  • Save your changes. This will ‘rest’ your permalink settings, and should rid you of the invalid JSON error in WordPress.

However, if you use a custom permalink structure, make sure there are no spelling mistakes or syntax errors with the tags you use:

The WordPress Post name and Custom Structure fields.

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:

WordPress' Site Health screen.

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 .htaccess File

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 .htaccess file.

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.

  • A suitable SFTP client, such as FileZilla, Cyberduck, or Transmit.
  • Knowledge of how to use SFTP, which we cover in a dedicated article on the blog.

Your .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):

A SFTP client showing a WordPress directory that contains a .htaccess file.

From here, make a duplicate on your computer, clear out the contents, and add the following:

# BEGIN WordPress
 
RewriteEngine On
RewriteRule .* - [E=HTTP_AUTHORIZATION:%{HTTP:Authorization}]
RewriteBase /
RewriteRule ^index\.php$ - [L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule . /index.php [L]
 
# END WordPress

This is a default .htaccess file. Save it as .htaccess, then upload it to your server again. From here, check for the error.

Conclusion

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!

+ Share
Disclosure

Tom Rankin

Tom Rankin is a quality content writer for WordPress, tech, and small businesses. When he's not putting fingers to keyboard, he can be found taking photographs, writing music, playing computer games, and talking in the third-person.

Related Posts

Back to all articles
  • WP Activity Log Review

    WP Activity Log Review: How to Secure Your Site and Log Activity

  • How to Stress Test WordPress Using a Free Tool (Full Guide)

  • How to Increase the Memory Limit in WordPress

    How to Increase the Memory Limit in WordPress

Coupons

View more deals
  • LearnDash Coupon Code!
    40% off

    LearnDash Coupon

    Searching for a LearnDash coupon to save on one of the top W
    Get This Deal
  • WP Activity Log Coupon
    20% OFF

    WP Activity Log Coupon

    Website security encompasses a whole host of elements, tasks, and
    Get This Deal
  • Recipe Card Blocks Coupon
    15% OFF

    Recipe Card Blocks Coupon

    Running a cooking or food website can be fun (and tasty) – but
    Get This Deal

Leave a Reply Cancel reply

Full Disclosure This post may contain affiliate links, meaning that if you click on one of the links and purchase an item, we may receive a commission (at no additional cost to you). All opinions are our own and we do not accept payments for positive reviews.

Our Newsletter

Get awesome content delivered straight to your inbox.

Thank you!

You have successfully joined our subscriber list.

.

THE BEST OF WPKUBE

Some of the best content we have published so far.

BEGINNER GUIDES & REVIEWS

18 Best Cheap WordPress Hosting Providers in 2023 (From $1.99)
210 Best WordPress Hosting Options for 2023 (Pros & Cons)
38 Best Managed WordPress Hosting Providers for 2023 Compared
45 Best WooCommerce Hosting Providers Compared in 2023 (All Budgets)
5Top 9 Landing Page Plugins for WordPress (2023)
69 Best List Building Plugins for WordPress In 2023
7How to Fix the 500 Internal Server Error on Your WordPress Website
8Thrive Themes Review: A Look At The Full Membership
9Beaver Builder Review: Is it The Best Page Builder Plugin for WordPress (2023)?
10OptimizePress Review: Create Landing Pages with Ease
11How to Make a Website: Complete Beginner’s Guide
12Top 22 Best Free Stock Photo Resources For Your Site
1317 of the Best Google Fonts for 2023 (And How to Use Them in WordPress)
14How to Start a Blog in 2022 (Step by Step Guide)
15How To Fix ‘503 Service Unavailable’ WordPress Error
1611 Best Contact Form Plugins for WordPress in 2023
17How to Add a Custom Logo to Your WordPress Site
18How to Fix Error Establishing a Database Connection in WordPress

WPEngine: 50% OFF Deal

Save 50% on one of the best managed hosting providers.

Get this Deal

Flywheel(our review)

Featured In Forbes Huffpost Entrepreneur SEJ

About WPKube

WPKube is an online WordPress resource which focuses on WordPress tutorials, How-to’s, guides, plugins, news, and more. We aim to provide the most comprehensive beginner’s guides to anything about WordPress — from installing plugins, themes, automated installs and setups, to creating and setting up pages for your website.

We have over 500+ tutorials, guides, product reviews, tips, and tricks about WordPress. Founded by Devesh Sharma, the main goal of this site is to provide useful information on anything and everything WordPress.

Twitter Facebook

Useful Links

  • Behind the Scenes
  • Beginner Guides
  • WordPress Hosting
  • WooCommerce Themes
  • MeridianThemes
  • Exclusive WordPress Deals
View All Guides »

Reviews

  • WPEngine 33% OFF
  • Thrive Leads
  • Flywheel 33% OFF
  • Divi Theme 20% OFF
  • Thrive Architect
  • Elegant Themes
Reviews »

Deals

  • InMotion Hosting
  • LifterLMS Coupon
  • LiquidWeb Coupon
  • WPEngine Coupon
  • A2 Hosting
  • FloThemes
More Deals »
© Copyright 2023 WPKube ® All Rights Reserved.
  • Contact
  • Site Terms
  • Disclosure
  • Privacy Policy