Every G.js script must tell the library where its output should go before any level content is created. This is done with a single call toDocumentation Index
Fetch the complete documentation index at: https://mintlify.com/g-js-api/G.js/llms.txt
Use this file to discover all available pages before exploring further.
$.exportConfig(), which accepts an ExportConfig object describing the export type and any additional options. Getting this call right — and getting it in before any GD objects, triggers, or groups are created — is the first step in every G.js project.
$.exportConfig(conf) — The Required Setup Call
$.exportConfig returns a Promise and must be await-ed. Place it at the very top of your script, immediately after your import statement and before any GD-related code.
The ExportConfig Interface
type selects the export destination. options is an optional bag of configuration flags described in the next section.
Export Types
'savefile' — Write Directly to the GD Save File
Saves the generated level directly into Geometry Dash’s local save file. This is the most common mode for desktop development.
G.js locates the save file automatically. Use the
path option to override the save file location if needed.'live_editor' — Stream to the WSLiveEditor Mod
Streams the level in real time to the WSLiveEditor Geometry Dash mod. This lets you preview changes without restarting the game.
'levelstring' — Return the Raw Level String
Exports the level as a raw GD level string and returns it from the exportConfig call. Store the result in a variable — it is not written anywhere automatically.
'gmd' — Export to a .gmd File
Writes the level to a .gmd file on disk. Geometry Dash can import .gmd files directly.
The ExportOptions Interface
All options are optional. Combine them as needed for your workflow.
When
true, prints a summary of level statistics (object count, group count, etc.) to the console when the script finishes. Great for debugging.When
true, G.js emits a warning if the level’s group count approaches the GD limit of 9999.The name of the level to create or overwrite in the save file. Defaults to a generic name if not set.
Override the path to the GD save file. Useful on non-standard installations or when using
'savefile' mode on a custom path.When
true, G.js re-encrypts the save file after writing, matching GD’s own save format.When
true, runs G.js’s built-in optimizer over the level before exporting. The optimizer merges redundant triggers and reduces group usage.When
true, removes objects previously added by G.js before writing the new ones. Use this with 'live_editor' mode to avoid accumulating objects across re-runs.Removes all objects belonging to the specified group before writing. Accepts either a raw group number or a
$group value (which carries a .value property).When
true, G.js is allowed to reposition triggers along the X axis for cleaner visual layout inside the editor. Requires trigger_pos_start to define the starting X offset.The X coordinate at which G.js begins placing triggers when
triggerPositioningAllowed is true.Path to the output
.gmd file. Only used with type: 'gmd'.Complete Examples
Using the Safe Import
If you prefer not to pollute the global scope, import from@g-js-api/g.js/safe and call exportConfig directly:
levelstring(string) — Parsing Existing Level Strings
G.js also exports a levelstring() helper (not to be confused with the export type) that parses an existing GD level string and returns an object with an .add() method. This lets you incorporate objects from existing levels into your script.
Type conversions are not done automatically when parsing with
levelstring(). Property values will be raw strings as they appear in the GD level format.Objects & Triggers
Create and configure GD objects and triggers in your level script.
Trigger Functions
Understand contexts and callable trigger groups.
Groups, Colors & Blocks
Work with GD group, color, and block IDs.
Quick Start
Get a full level running in minutes.