---
title: "diff | JavaScript maps SDK"
description: "Documentation for MapTiler SDK"
---

> For AI agents: a documentation index is available at [/llms.txt](https://docs.maptiler.com/llms.txt). Markdown versions of all pages are available by appending .md to any URL.

# Function diff

-   diff(  
        before?: [StyleSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/StyleSpecification/),  
        after: [StyleSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/StyleSpecification/),  
    ): [DiffCommand](https://docs.maptiler.com/sdk-js/api-reference/types/DiffCommand/)<keyof [DiffOperationsMap](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.DiffOperationsMap/)\>\[\][](#diff)
    
    Diff two stylesheet
    
    Creates semanticly aware diffs that can easily be applied at runtime. Operations produced by the diff closely resemble the maplibre-gl-js API. Any error creating the diff will fall back to the 'setStyle' operation.
    
    Example diff: \[ { command: 'setConstant', args: \['@water', '#0000FF'\] }, { command: 'setPaintProperty', args: \['background', 'background-color', 'black'\] } \]
    
    #### Parameters
    
    -   `Optional`before: [StyleSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/StyleSpecification/)
        
        stylesheet to compare from
        
    -   after: [StyleSpecification](https://docs.maptiler.com/sdk-js/api-reference/types/StyleSpecification/)
        
        stylesheet to compare to
        
    
    #### Returns [DiffCommand](https://docs.maptiler.com/sdk-js/api-reference/types/DiffCommand/)<keyof [DiffOperationsMap](https://docs.maptiler.com/sdk-js/api-reference/types/Externals.DiffOperationsMap/)\>\[\]
    
    Array list of changes
    
    #### Private[](#private)
