How can I create the API for this website, https://jsonformatter.org

I am working on application where I need to format and validate JSON data and need to create API so other services can Valdiate and Format the JSON data.

Here are few sites, which does that.

Best JSON Viewer and JSON Beautifier Online.

So How can I develop an API which gives result similar to these sites.

thanks,
Vijay