Run a script
Sketch can run scripts from two places:
- The built-in script editor in the Plugins menu
- A JavaScript file bundled with a plugin
1. Write a script using the built-in script editor
The script editor provides full access to the JavaScript API and Internal API.
- Open a new or existing file in Sketch
- Select Run Script… from the Plugins menu or use the keyboard shortcut
control + shift + k
to bring up the code editor - Paste in the code below
const sketch = require('sketch')
sketch.UI.message('Hello Sketch 👋')
2. Run the script
Click Run in the script panel or use command + return
keyboard shortcut and a message will be shown at the bottom of your Sketch Document window saying Hello Sketch 👋.
3. Save the script as a plugin
Save the script as a plugin to use it later by clicking the Save button in the Run Script… panel.
- Enter a name for the plugin, e.g. show message
- Click Save
The newly created plugin is now available from the Plugins menu.
Next Steps
Check out these resources to learn more about plugins.
See something wrong or
incomplete?
Improve this page.