G.js includes a level-reading API that lets your scripts open existing Geometry Dash levels, inspect or modify their objects, and write the result back to disk. This is useful for procedural modifications, automated edits, object filtering, and building tools that work on top of levels you’ve already designed in the GD editor.Documentation 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.
LevelReader
LevelReader opens a level by name from a GD save file (the standard CCLocalLevels.dat or a custom path).
| Parameter | Type | Default | Description |
|---|---|---|---|
level_name | string | — | Name of the level to load from the save file |
filename | string | (default GD path) | Path to the GD save file to read from |
reencrypt | boolean | true | Whether to re-encrypt the file when saving |
Properties and Methods
| Member | Type | Description |
|---|---|---|
.data | any | Parsed level data (object representation of the level) |
.set(lvlstr) | function | Replace the level’s object data with a new level string |
.save() | Promise<void> | Write the modified level back to the save file |
Example — Filter and Re-save a Level
SingleLevelReader
SingleLevelReader reads a standalone .gmd level file rather than GD’s main save file. The .gmd format is produced by GD’s “Export Level” feature and is useful for sharing individual levels as files.
| Parameter | Type | Description |
|---|---|---|
filename | string | Path to the .gmd file to open |
Properties and Methods
| Member | Type | Description |
|---|---|---|
.data | any | Parsed level data |
.root | any | Raw root-level data from the file |
.set(lvlstr) | function | Replace the level string |
.add(lvlstr) | function | Append objects from a level string to the existing level |
.save(f?) | function | Save back to disk; optionally provide an alternate output path |
Example — Append Objects to a .gmd File
encode_level() and decode_level()
G.js exposes low-level helpers for converting between raw GD level strings and their decoded form.
| Function | Signature | Description |
|---|---|---|
encode_level | encode_level(level_string) | Encodes a plain level string into GD’s save format |
decode_level | decode_level(data) | Decodes an encoded GD level string back to plaintext |
The level Object
During level generation, G.js exposes a level helper object that provides access to already-added objects and the current level string. This is useful for reading back information about the level you are actively building.
| Member | Type | Description |
|---|---|---|
level.objects | any[] | Array of all objects added to the level so far |
level.raw_levelstring | string | The raw level string representation of current objects |
level.get_objects(prop, pattern) | function | Filter objects by a property key and a pattern function |
level.get_objects(prop, pattern)
prop can be a numeric GD property ID or a string key name.
levelstring() and levelstring_to_obj()
These utilities let you import or parse level strings within your generation scripts.
levelstring(string)
Parses a level string and returns a helper object with the parsed objects and an add() method that inserts all of them into the current level.
levelstring_to_obj(string)
A lower-level converter that takes a raw level string and returns an array of Dictionary objects without doing any processing or type conversions. Use this when you need direct access to raw GD property maps.
Complete Workflow Example
The following shows a realistic workflow: open an existing level, find all spike objects (GD ID8), move them 30 units upward, and save the result.
Safe Mode
Import only what you need without polluting global scope.
Export Modes
Learn about savefile, levelstring, live_editor, and gmd export types.
Objects & Triggers
Understand the GJsObject model and how .add() works.
General Purpose API
Reference for levelstring, level, and other general utilities.