How To Allow JSON File Uploads In WordPress

Published: 9 months ago

JSON files are a great way of storing data, but WordPress blocks their upload by default. Here's how to allow JSON File Uploads In WordPress.

Saving JSON responses to your model in Scala

We ran into this issue when trying to integrate Lotties into our sites, as they come in .JSON format. For security reasons, WordPress will block them from upload. To fix this, we need to add a new MIMEType for JSON, excluding that filetype from the security rules. Once implemented, you can upload a JSON to your WordPress media library, just as you do with images. Self hosting reduces third party requests and speeds up your site.

Install this code using Advanced Scripts or Code Snippets (simply copy paste) and toggle it on. Then just drag and drop your JSON into the media library.

function cc_mime_types($mimes) {
$mimes['json'] = 'application/json'; 
$mimes['svg'] = 'image/svg+xml'; 
return $mimes; 

add_filter('upload_mimes', 'cc_mime_types');

Here's where that code's from: StackOverflow article. This actually allows you to upload both JSON and SVGs.

The is an actual security risk here, so turn it on to upload your files, then toggle it off until you need to add a new JSON to your WordPress site. Also, PLEASE sanitize and scan the files for any issues/malicious elements. JSON security. SVG security.

There's also a Plugin that we've used in the past, which allows you to toggle many different MIME (file) types on your site. If you need a bit more power, check it out:

Join Our Newsletter
Here's what you get: A once a week newsletter that contains original content, aggregated posts, WordPress deals, and anything else we think you'd like. We don't spam or sell your email address. Unsub at any time.
Notify of
Newest Most Voted
Inline Feedbacks
View all comments
4 months ago

Thanks a lot James! Didn't seem to work for me though, added your code via code snippets, and still not going through. Could it be on the server side? I'm hosted via vultr on Cloudways..

Also by the way, great commenting interface.. what plugin are you using for commenting?

Last edited 4 months ago by Solomon
4 months ago

Thanks for this, very helpful!

IsoGroup- Web Dev/Design, WordPress and More

Affiliate Disclosure: Some links on this website are affiliate links. We make commissions for purchases made through those links.

We only recommend items/tools that we've personally used and like.

Full Disclosure | FTC Statement

Join Our Newsletter
Over 4,000 Design Lovers and Problem Solvers.


A relationship driven website creation company.


© ISOTROPIC, LLC 2016-2021
linkedin facebook pinterest youtube rss twitter instagram facebook-blank rss-blank linkedin-blank pinterest youtube twitter instagram