Home > Develop > Custom processing scripts

Custom processing scripts

Custom Processing Scripts

Custom scripts are a piece of Javascript code you provide and are the way you control what values the Sentinel-Hub services will return. Each of your layers requires a custom script. This is configurable in the Configuration Utility and a multitude of pre-configured scripts are available which you may use directly or modify as necessary.

The script can use any Javascript function or language structures, as long as a valid array of numbers with fixed number of elements is returned at any point. The number of the returned array elements represent the number of the components in the output image. Note that JPEG and PNG can only support 1 or 3 color components (plus an alpha channel, if set).

Get started

For complete beginners, check out this basic tutorial under our Education page.

Here is another tutorial , where you can learn the basics, along with the difference between simple and extended scripts.

Available Custom Scripts

You can see the premade custom scripts, which include indices, bands and composites, under Data products for every data source.

Many custom scripts are available online, on the Custom Script Repository github.

You can participate in the Custom Script Contest and submit your scripts to earn a reward and contribute to the community. You can read about the 2019 contest here.


Read about custom scripts in the following Medium blog posts.

Create Useful and Beautiful Satellite Images with Custom Scripts

Multitemporal deforestation detection blog by Nicolas Karasiak

The 2019 Custom script contest blog

Read our Custom scripts: faster, cheaper, better! blog post on the best scripting practices, to learn how to write better scripts with lower processing time and higher readability.


Custom processing scripts currently exist in 3 versions. The first two were used mainly in the OGC instances, while the new Sentinel Hub API uses the third version. Each consecutive version allows for more features and flexibility within custom scripts.

See the documentation on versions 1 and 2.

See the documentation on version 3.


Beside the standard Javascript functions, Sentinel WMS service also provides two additional utility functions:

Utility functions info

colorMap(inputNumber, indexArray, outputValueArray)

This method returns the value in "outputValueArray" at the same index as is the location of "inputValue" in the "indexArray". For example, when indexArray = [0, 0.2, 0.4], inputValue in the interval [0, 0.2) will make coloMap to return the outputValueArray value at index 0, inputValue in the interval [0.2, 0.4) will return value at index 1, etc. InputValue lesser than the first indexArray value will return the first value in outputValueArray and inputValue greater than the last indexArray value will return the last outputValueArray value. outputValueArray can contains single numbers or even arrays of numbers (in which case, colorMap will return an array instead of a single number).

  Example of colorMap:

var value = colorMap(B04, [0, 0.2, 0.4, 0.6, 0.8, 1], [0, 0.1, 0.25, 0.4, 0.75, 1]); return [value, value, value];

colorBlend(inputNumber, indexArray, outputValueArray)

similar to colorMap, except the returned value is interpolated between two consecutive values in outputValueArray.

  Example of colorBlend:

return colorBlend(B04, [0, 0.2, 0.4, 0.6, 0.8, 1], [[0,0,0], [0.1,0.2,0.5], [0.25,0.4,0.5], [0.4,0.6,0.5], [0.75,0.8,0.5], [1,1,0.5]]);

Functions you can use in evalscript version 3 are explained here.


There are multiple visualization options possible.

Please see https://test-www.sentinel-hub.com/develop/documentation/faq#t31n434 for more info on Visualizers.

Some visualization methods were made for the older versions of evalscript, but can be modified to work in the newer ones. See this documentation to learn more.


If you come across an error, or the script is not working, the following might help.

If an exception is thrown from a script then request execution is stopped and response with the exception message will be returned (note that formatting of the message depends on the service endpoint), which can be used as a simple debugging tool.

Debugging basic scripts example:

let message = "Hello world";
throw new Error(message);

// response: "Failed to evaluate script! Error: Hello world"

Debugging extended scripts example:

function setup(dataSource) {
    let message = "Hello world";
    throw new Error(message);

function evaluatePixel(samples) {
    // ...

// response: "Failed to evaluate script! Error: Hello world"