23

I'm looking for a plugin that can check the current opened file and instantly tell me whether it is valid JSON or not (eg whether there's a comma or a bracket missing) — is there any? I'm currently using JSONView on Chrome but it's a pain to always go check the file in the browser and back.

I'm often writing data in json by hand, hence why I feel this could save me a lot of time.

Mahn
  • 852
  • 2
  • 10
  • 22
  • Not a plugin for Notepad++ but XML ValidatorBuddy is also a JSON editor and comes with a built-in JSON syntax checker and auto-completion. It is a standalone Windows tool. – Clemens Oct 23 '12 at 09:38
  • You can use Codverter JSON Validator: https://codverter.com/src/jsonvalidator it`s highly secure and everything you do is interpreted on your local computer and never sent back to the server. the validation error messages are informative and accurate. (Full Disclosure: I am one of the developers). – Jonathan Applebaum Mar 11 '19 at 17:25

2 Answers2

10

You might be able to use a JSON formatter to accomplish the task (since it would likely complain or do something wrong -- say, like indent improperly -- if the JSON's invalid). See Is there an extension to reindent JSON in Notepad++?. Similarly, there's a JSONViewer Notepad++ plugin the might help in the same way.

Another less-than-ideal alternative would be to just use one of the online JSON validators.

martineau
  • 4,447
  • 23
  • 29
  • 1
    +1 for JSON Viewer- I use it all the time. can also format/reindent your JSON string. Only thing is you have to manually use the functionality- I don't think you can do it every time a .json file is opened – Robotnik Jul 09 '12 at 00:16
  • Thanks, I upvoted, but it's still not quite what I hoped for; JSMin ignores errors, and JSON Viewer while it does fail if the json is not properly formatted, I still get much more if I parse it using JSONView in Google Chrome since as opposed to JSON Viewer it tells exactly what is missing and where. Oh well. I suppose I can only hope someday somebody able to code npp plugins comes across this and implements a simple one-button solution to parse and validate json. – Mahn Jul 09 '12 at 16:26
  • @Mahn: Thanks. _Necessity is the mother of invention_, so perhaps you should be that someone... – martineau Jul 09 '12 at 16:54
  • I'd love to, but I'm involved in a somewhat big project atm and time is ticking out :) maybe someday. – Mahn Jul 09 '12 at 19:56
  • It's worth noting that the JSONView Chrome extension does a great job but crashes on significantly large files (can't get it to process a 90meg file... not sure what it's limit is though). – Sean Colombo Feb 18 '16 at 17:04
  • Online JSON validators are not an option if you have sensitive personal data stored in the JSON. – Andreas Aug 12 '20 at 06:13
  • Yeah, most companies don't like you copy/pasta-ing config, etc json files up into the public interwebs. If you use JSONView -> Format Json, it will throw an error and select the problematic area of the JSON document. I'm sure it could be made to be fancier and provide more of an explanation, but it works well enough for my needs. – Dan Csharpster Mar 01 '22 at 16:05
4

There is plugin for NPP+ called JSLint. It is a plugin to validate JavaScript-code, but it works also just fine with JSON-files.

techraf
  • 4,852
  • 11
  • 24
  • 40
Michael
  • 41
  • 1
  • 3
    Does not seem to work for me. It says "JSLint can operate only on JavaScript, HTML or CSS files". Saving my .json file as .js file does not help. – Mikhail Jan 14 '17 at 14:02
  • Works just fine when saving the file as JavaScript file running Notepad++ 7.8.7 and JSLint 0.8.3.199. Remember to open the copy if you chose "Save a copy" from the file menu before running JSLint. – Andreas Aug 12 '20 at 06:10
  • I had to save my json file with the .js extension first – Matthew Jul 05 '21 at 00:05