What does the Standard JSON to DynamoDB JSON Converter do?
The Standard JSON to DynamoDB JSON Converter & Marshaller transforms clean standard JSON objects or arrays into typed AWS DynamoDB attribute descriptors ({"S": "..."}, {"N": "..."}, {"BOOL": true}, {"M": {...}}, {"L": [...]}). It generates structured document JSON for AWS CLI PutItem commands, SDK calls, and batch transaction payloads.
Core Concepts
Understanding DynamoDB JSON marshalling mechanics:
- Type Descriptor Wrapping: Maps native primitive types and composite objects to AWS DynamoDB data types (
Sfor Strings,Nfor Numbers,BOOLfor Booleans,NULLfor Nulls,Mfor Maps,Lfor Lists, andSS/NS/BSfor Sets). - Batch Array Marshalling: Accepts arrays of standard JSON records and marshals each item individually into a valid DynamoDB batch write payload.
- Undefined Attribute Filtering: Offers optional filtering to strip undefined or empty attributes before writing to database tables.
How to use the tool?
- Enter Standard JSON: Paste your application JSON object or array into the input pane or click Load Sample.
- Configure Options: Optionally check Skip Undefined Attributes.
- Convert & Copy: Click Convert to DynamoDB JSON, then click Copy or Download to export the marshalled attribute JSON.
Related Developer Utilities
If you work with AWS DynamoDB, cloud databases, and JSON structures, explore these complementary tools:
- DynamoDB JSON to Standard JSON Converter: Unmarshall typed DynamoDB records back to clean standard JSON.
- JSON Formatter: Format and validate structured JSON documents.
- JSON Syntax Validator: Validate JSON payloads and locate syntax errors.
- cURL to AWS SigV4 Converter: Convert HTTP cURL calls into signed SigV4 headers.
REST API Integration
Blueutils provides a free REST API endpoint (POST https://blueutils.com/api/aws/json-to-dynamodb) to programmatically convert clean standard JSON structures into verbose DynamoDB attribute types.
API Request Parameters
| Name | Type | Description | Example |
|---|---|---|---|
rawText |
String | Input clean standard JSON string payload to marshall. | "{ \"pk\": \"user#102\" }" |
options.removeUndefinedValues |
Boolean | Optional. Strip undefined attributes. Default: false. |
false |
API Request Payload Examples
cURL
curl -X POST https://blueutils.com/api/aws/json-to-dynamodb \
-H "Content-Type: application/json" \
-d '{
"rawText": "{\"pk\": \"user#102\", \"age\": 34, \"isActive\": true}",
"options": { "removeUndefinedValues": false }
}'Python
import requests
url = "https://blueutils.com/api/aws/json-to-dynamodb"
payload = {
"rawText": '{"pk": "user#102", "age": 34, "isActive": true}',
"options": {"removeUndefinedValues": False}
}
headers = {"Content-Type": "application/json"}
response = requests.post(url, json=payload, headers=headers)
print(response.json())Java
import java.net.URI;
import java.net.http.HttpClient;
import java.net.http.HttpRequest;
import java.net.http.HttpResponse;
public class Main {
public static void main(String[] args) throws Exception {
String jsonPayload = """
{
"rawText": "{\\"pk\\": \\"user#102\\", \\"age\\": 34}",
"options": { "removeUndefinedValues": false }
}
""";
HttpClient client = HttpClient.newHttpClient();
HttpRequest request = HttpRequest.newBuilder()
.uri(URI.create("https://blueutils.com/api/aws/json-to-dynamodb"))
.header("Content-Type", "application/json")
.POST(HttpRequest.BodyPublishers.ofString(jsonPayload))
.build();
HttpResponse<String> response = client.send(request, HttpResponse.BodyHandlers.ofString());
System.out.println(response.body());
}
}API Response Parameters
| Name | Type | Description | Example |
|---|---|---|---|
isValid |
Boolean | Indicates whether marshalling succeeded. | true |
outputText |
String | Marshalled DynamoDB attribute JSON string. | "{\n \"pk\": {\n \"S\": \"user#102\"\n }\n}" |
API Response Payload Examples
Success Response (HTTP 200 OK)
{
"isValid": true,
"outputText": "{\n \"pk\": {\n \"S\": \"user#102\"\n },\n \"age\": {\n \"N\": \"34\"\n },\n \"isActive\": {\n \"BOOL\": true\n }\n}"
}Validation Failure Response (HTTP 400 Bad Request)
{
"isValid": false,
"error": "Input Standard JSON string payload cannot be empty."
}Rate Limit Exceeded Response (HTTP 429 Too Many Requests)
{
"error": "API rate limit exceeded. Please wait or contact support@blueutils.com."
}Why use an API to convert standard JSON to DynamoDB?
Integrating the Standard JSON to DynamoDB API into serverless functions, database migration jobs, or AI agent tool calling provides key benefits:
- Rapid Script Validation: Converts application state objects directly into typed DynamoDB attribute formats before executing AWS CLI
PutItemcommands. - Optimized Token Efficiency for AI Agents: LLMs frequently mix up DynamoDB type wrappers (
{"S": ...}vs{"N": ...}). Calling the API types attributes deterministically without token consumption. - Deterministic Accuracy Without Hallucinations: Uses official AWS SDK marshalling rules for 100% compliant attribute formatting.
Native Usage
How to convert standard JSON to DynamoDB JSON locally in terminal environments or scripts:
Windows (CMD / PowerShell)
# Marshall standard JSON using Node.js in PowerShell
node -e "const { marshall } = require('@aws-sdk/util-dynamodb'); console.log(JSON.stringify(marshall(JSON.parse(process.argv[1])), null, 2))" '{\"pk\": \"user#12\", \"age\": 30}'Linux / Unix (Bash)
# Marshall standard JSON using Node.js in Linux
node -e "const { marshall } = require('@aws-sdk/util-dynamodb'); console.log(JSON.stringify(marshall({pk: 'user#102', age: 34}), null, 2))"Python
Using Python boto3:
from boto3.dynamodb.types import TypeSerializer
import json
serializer = TypeSerializer()
standard_data = {"pk": "user#102", "age": 34, "isActive": True}
dynamodb_data = {k: serializer.serialize(v) for k, v in standard_data.items()}
print(json.dumps(dynamodb_data, indent=2))Java
Using AWS SDK for Java v2:
import software.amazon.awssdk.services.dynamodb.model.AttributeValue;
import java.util.Map;
import java.util.HashMap;
public class DynamoDbMarshaller {
public static void main(String[] args) {
Map<String, AttributeValue> item = new HashMap<>();
item.put("pk", AttributeValue.builder().s("user#102").build());
item.put("age", AttributeValue.builder().n("34").build());
item.put("isActive", AttributeValue.builder().bool(true).build());
System.out.println("Marshalled item: " + item);
}
}