Working with Desmos Text I/O

Desmos Text I/O is a browser extension that enables importing and exporting Desmos graphs as text/JSON. This extension works seamlessly with Desmos.jl, allowing you to transfer graphs between Julia and the Desmos web interface.

Installation

The extension is available for multiple browsers:

How It Works

Desmos Text I/O allows you to:

  1. Export from Desmos: Copy the JSON state of any Desmos graph to your clipboard
  2. Import to Desmos: Paste JSON state to recreate a graph in Desmos
  3. Share graphs as text: Store and share complete graph configurations as JSON

This makes it easy to:

  • Transfer graphs created in Julia to the Desmos web interface
  • Import existing Desmos graphs into your Julia workflow
  • Share reproducible graph configurations with collaborators

Exporting from Julia to Desmos

  1. Enable clipboard mode in the display configuration
  2. Create your graph in Julia using Desmos.jl
  3. Click the clipboard export button in the rendered plot pane (alternatively, run clipboard_desmos_state)
  4. Open Desmos Graphing Calculator
  5. Use the Desmos Text I/O extension to import the copied JSON
using Desmos

# 1. Enable clipboard mode
Desmos.set_desmos_display_config(clipboard=true)

# 2. Create your graph
state = @desmos begin
    @text "My graph"
    @expression sin(x) + cos(2x)
    @expression y = x^2
end

# 3. Click the clipboard export button in the rendered plot pane (alternatively, run `clipboard_desmos_state(state)`)
# 4. Open [Desmos Graphing Calculator](https://www.desmos.com/calculator)
# 5. Use the Desmos Text I/O extension to import the copied JSON

Importing from Desmos to Julia

The easiest way to import a graph from Desmos is using the clipboard_desmos_state function:

  1. Open a graph in Desmos Graphing Calculator
  2. Use the Desmos Text I/O extension to export the graph as JSON to your clipboard
  3. In Julia, import the graph directly:
using Desmos

# Import the graph state from clipboard
state = clipboard_desmos_state()

The function reads JSON data from the system clipboard and parses it into a DesmosState object.

Working with the Clipboard

The clipboard_desmos_state function works both ways:

Exporting to Clipboard

using Desmos

state = @desmos begin
    y = sin(x) * cos(2x)
    y = x^2 - 3
end
# Copy the state to clipboard as JSON
clipboard_desmos_state(state)
# Now you can paste it into Desmos using the Text I/O extension

Round-trip Example

# 1. Create and export a graph
state = @desmos begin
    f(x) = x^2
end
clipboard_desmos_state(state)

# 2. Edit in Desmos web interface, then export using Text I/O extension

# 3. Import the modified graph back to Julia
modified_state = clipboard_desmos_state()

Saving and Loading Graphs

You can save graph configurations as JSON files for reproducibility:

using Desmos, JSON

state = @desmos begin
    @expression f(x) = sin(x) * exp(-x/10)
end

# Save to file
open("my_graph.json", "w") do io
    JSON.print(io, state, 2)
end

# Load later
loaded_state = JSON.parsefile("my_graph.json")
JSON.Object{String, Any} with 6 entries:
  "version"                 => 11
  "randomSeed"              => "00000000000000000000000000000000"
  "graph"                   => Object{String, Any}()
  "expressions"             => Object{String, Any}("list"=>Any[Object{String, A…
  "includeFunctionParamete… => true
  "doNotMigrateMovablePoin… => true

See the Display Configuration page for details on enabling clipboard mode and other display options that enhance the Desmos Text I/O workflow.