Photopea API

Passing data to Photopea

Photopea can be configured using a single GET parameter p having a string value.

String value is encoded into the URL using classic encoding of query parameters (space as %20 etc.). It corresponds to encodeURI() in Javascript or urlencode() in PHP. This string contains a JSON object.

JSON configuration object

JSON object must have the following structure:

	"files" : [
	"resources" : [
	"server" : {
		"url" : "",
		"formats" : [ "psd", "png", "jpg:0.5" ]
	"environment" : {
		"fcolor" : "0xff0000",   "bcolor" : "0x000000",     "rulers"  : true, 
		"compact" : true,        "theme"  : 2,              "lang"   : "es",   
		"localsave" : false,     "autosave"  : 120,         "showbranding": false,     
		"showtools" : [0,5,9],   "showmenus" : [ [0,1,3], 1, 0, 1, [0] ],
		"phrases"   : [ [1,0], "Open Design", [1,2], "Save Design" ]

Data URIs can be used - file can be passed inside request (test).


Saving to server

When server parameter is specified in a request to, your project will get the File - Save (To Server) option. After a user clicks it, project data are sent to your server in HTTP request using POST method. It will contain a single string parameter p. The string contains a JSON object with the following structure:

	"source" : "",
	"versions" : [
		{"format":"psd", "data": "..."},
		{"format":"jpg", "data": "..."},


Here is a short PHP example, which accepts files from Photopea.

$p = json_decode( $_POST["p"] );	// parse JSON
// getting file name from "source";
$fname = substr ($p->source, strrpos($p->source,"/")+1);	
file_put_contents("images/".$fname, base64_decode( $p->versions[0]->data ));

Live demo

Cross-Origin Resource Sharing

For security reasons, webapps can access only files from the same domain. In order to let Photopea load your file, the response of your server must contain

Access-Control-Allow-Origin: *

in its HTTP header. Find out more at CORS specification or at


Usage of Photopea API is completely free. Keep in mind, that PP is in early stages of development and there may be critical bugs. We do not take any responsibility for projects edited or generated by Photopea.

Please, let us know in advance (, when you expect to have a large regular traffic (thousands of visitors per day).