Bind Text and Shapes to CSV or JSON in After Effects
Automating motion graphics with external data allows you to quickly generate dynamic infographics, lower thirds, and localized content without manual entry. In Adobe After Effects, you can import structured files such as CSV, TSV, or JSON directly into your project and link their contents to layer properties using simple expressions. This guide explains how to import your data, target specific values, and bind those values to text source fields and shape layer properties like size, position, and color.
1. Import and Add the Data File to the Timeline
- Drag and drop your
.csvor.jsonfile into the Project panel. - Drag the imported data file from the Project panel into your active Composition timeline.
After Effects treats the data file as a layer. Expanding the layer reveals a Data section showing the hierarchy of keys, arrays, and values contained within the file.
2. Binding Data to Text Layers
To dynamically drive the content of a text layer from your data source:
- Create a new text layer in your composition.
- Twirl open the text layer to reveal the Text group and find the Source Text property.
- Hold
Alt(Windows) orOption(macOS) and click the stopwatch next to Source Text to enable expressions.
For CSV Files
CSV files are accessed using column and row coordinates with the
dataValue() method:
var dataFile = footage("data.csv");
var columnIndex = 0; // First column
var rowIndex = 1; // Row index (0 is typically headers)
dataFile.dataValue([columnIndex, rowIndex]);For JSON Files
JSON data can be accessed directly using standard object notation
through sourceData:
var dataFile = footage("data.json");
dataFile.sourceData.user.name; // Targets a nested key
// Or target an array index:
// dataFile.sourceData.items[0].title;Alternatively, use the pick-whip tool next to the
Source Text expression field and drag it directly to the
specific data line inside the data layer on your timeline.
3. Binding Data to Shape Layer Properties
Shape attributes require specific data types (such as numbers or arrays). You must format your incoming data to match the expected property format.
Binding to Size or Scale (2D Array)
Scale and size properties expect an array of two values:
[x, y].
- Alt/Option-click the stopwatch on the shape's Size (under Rectangle Path) or the layer's Scale.
- Read the numeric data point and output an array:
// For JSON:
var val = footage("data.json").sourceData.chartValues[0].height;
[value[0], val]; // Maintains existing width, overrides height
// For CSV:
var val = footage("data.csv").dataValue([1, 1]);
[val, val]; // Applies equal scale to X and YBinding to Position (2D Coordinates)
If your data file includes X and Y coordinates:
var posX = footage("data.json").sourceData.points[0].x;
var posY = footage("data.json").sourceData.points[0].y;
[posX, posY];Binding to Fill Color
After Effects color properties use an RGBA array where values range
from 0 to 1 (rather than standard 8-bit
0 to 255 values).
To bind RGB values from your data source:
var r = footage("data.json").sourceData.theme.r / 255;
var g = footage("data.json").sourceData.theme.g / 255;
var b = footage("data.json").sourceData.theme.b / 255;
[r, g, b, 1]; // [Red, Green, Blue, Alpha]To parse a Hex color string (e.g., #FF5733) stored in
the data source:
var hex = footage("data.json").sourceData.theme.hexColor;
function hexToRgba(hex) {
hex = hex.replace("#", "");
var r = parseInt(hex.substring(0, 2), 16) / 255;
var g = parseInt(hex.substring(2, 4), 16) / 255;
var b = parseInt(hex.substring(4, 6), 16) / 255;
return [r, g, b, 1];
}
hexToRgba(hex);4. Driving Rows Dynamically with Expression Controls
To iterate through datasets without changing expression code:
- Add a Slider Control to an adjustment layer or a null layer via Effect > Expression Controls > Slider Control.
- Reference the slider value as the row or array index in your text and shape expressions:
var index = Math.round(thisComp.layer("Controller").effect("Slider Control")("Slider"));
footage("data.csv").dataValue([0, index]);Keyframing this slider will automatically cycle your visual elements through the corresponding rows in your dataset.