Seeing “Migration failed. Unexpected character in json data” or a browser message like “JSON.parse: unexpected character at line 1 column 1 of the JSON data” in WP Migrate Lite usually means this:
The plugin expected a clean JSON response from WordPress.
Instead it received HTML, PHP warnings, or some other text.
Most of the time the real problem is a PHP notice or error from another plugin, or corrupted serialized data that WP Migrate cannot safely read. Below is a step by step path to see the real error, narrow it down to a table or plugin, and then complete your migration cleanly.
WP Migrate Lite shows “Migration failed. Unexpected character in json data” and sometimes “JSON.parse: unexpected character at line 1 column 1 of the JSON data”. How do I fix this?
The short version: WP Migrate Lite is not actually broken.
It is getting back something that is not valid JSON. Your browser then complains.
We need to see what that “something” is, and then fix the source.
To make this easier, here is a quick map:
WPMDB Error: Data cannot be unserialized, skip to Fix serialized data issues.WP Migrate Lite runs migrations over AJAX.
JavaScript calls admin-ajax.php.
The server should respond with a small JSON blob.
Your browser tries to parse it.
When you see:
it means the first character of that response was not valid JSON.
Often it is:
< from an HTML error page.P from a PHP warning.So our job is to see the raw response, then fix the thing that is being printed there.
First confirm what the browser is getting back.
admin-ajax.php with an action related to wpmdb or wp_migrate.You will usually see one of these:
var_dump or print_r.Whatever is in that response is what we need to fix.
If the response is totally blank or looks like valid JSON, but the UI still complains, move on to log based debugging.
We want a record of any PHP errors that fire during the migration.
Edit your wp-config.php file on the site where the migration is running.
Add or update these lines above the line that says /* That's all, stop editing */.
Use a code editor or the file manager from your host.
define( 'WP_DEBUG', true );
define( 'WP_DEBUG_LOG', true );
define( 'WP_DEBUG_DISPLAY', false );
Save the file.
This sends PHP warnings and notices into a file at:
wp-content/debug.log
wp-content/debug.log.You are looking for anything that lines up with the time of the failure.
Common patterns:
WPMDB Error: Data cannot be unserialized.If you see WPMDB Error: Data cannot be unserialized, go to the next section.
If you only see errors from another plugin, skip to Fix third party plugin or database errors.
When you see log lines like:
WPMDB Error: Data cannot be unserialized. Scope: DeliciousBrains\WPMDB\Common\Replace::recursive_unserialize_replace()
it means WP Migrate tried to read a WordPress field that is supposed to contain a serialized array, but the data is corrupted.
This can happen if:
Often the debug log will also show which table and option or meta key is affected, for example:
WPMDB Find & Replace skipped: {"table":"wp_options","option_name":"some_plugin_option"}
If the problematic data belongs to a non critical plugin, the fastest fix is to skip it.
In WP Migrate Lite:
If the error disappears, you know it was that table.
You can usually reinstall or reconfigure that plugin on the target site after the migration.
If the log tells you a specific option or meta key is broken and you need that data:
wp_options.If the migration now runs, the corrupted serialized value was the trigger for the JSON error.
In many real world cases the JSON error is only a side effect.
The true problem is a plugin or custom code that throws errors during any request, including AJAX.
In the WordPress forums you will often see logs with lines like:
Those lines can get mixed into the AJAX response that WP Migrate expects to be clean JSON.
A quick test:
If the migration runs cleanly with plugins disabled, then:
The plugin that brings the error back is the one writing to the AJAX response or triggering a fatal.
If the log shows repeated “WordPress database error” entries from a specific plugin, you have two choices:
For example, if a security plugin is logging errors about a missing lockouts table on every request, that noise can show up in the WP Migrate AJAX response.
Fixing or excluding that table typically removes the JSON error on migration.
Sometimes the response is not PHP errors at all.
Instead the server or a firewall is blocking or truncating the AJAX request.
Signs this is the case:
If that matches what you saw in the Network tab:
Ask your host, or change if you can:
admin-ajax.php.After your host adjusts these, run the migration again and watch the AJAX response. It should now be valid JSON.
If you still cannot see a clear cause, you can binary search the database.
The idea is simple. Migrate smaller sets of tables until you find the one that triggers the JSON error.
wp_optionswp_postswp_postmetawp_userswp_usermetaOnce you know the exact table, you can:
After you make changes and rerun the migration, check that all is well.
You should see:
wp-content/debug.log no longer fills with new errors during a migration run.If everything looks good, you can leave WP_DEBUG on or set it back to false in wp-config.php once you are finished troubleshooting.
If you are still seeing the JSON error and cannot spot the cause, I can walk through your logs and setup with you.
Hit Continue Chat below and send:
wp-content/debug.log around the time of the failure.Together we can pinpoint which plugin, table, or server layer is breaking the JSON.
Scroll down to the contact form below. Enter your name, email, and WordPress needs. Atiba will get back to you as soon as possible.
WP Assistant is a free tool created by Atiba Software, a WordPress design and development company located in Nashville, TN. If you need more personalized WordPress assistance let us know, and we’ll get back to you ASAP!