Boto3 to AWS SDK v3 Converter: Python to TypeScript
Paste Python boto3 code and get TypeScript that uses the modular @aws-sdk/client-* packages of AWS SDK for JavaScript v3, ready for Node.js services and Lambda functions.
This looks like it contains a secret.
Your code is sent to an AI service for conversion. Replace real keys and tokens with placeholders before converting.
How to convert boto3 code to AWS SDK v3
To convert boto3 code to AWS SDK for JavaScript v3, paste your Python into the editor above and press Convert to TypeScript. Each boto3.client() becomes a v3 client, each call becomes await client.send(new SomethingCommand(params)), and functions become async. Then install the imported @aws-sdk/* packages and type-check the result.
Add your boto3 codePaste a Python module into the Python (boto3) editor, use Open file for a .py file up to 500 KB, or drag the file onto the editor. Sample loads a function that reads a DynamoDB item and archives it to S3.
Let the secret check runBefore anything is sent, the page scans for AWS access keys, secret keys, private keys and common API tokens. Scripts often set aws_access_key_id inline; replace those with placeholders when the check flags them.
Convert to TypeScriptClick Convert to TypeScript or press Ctrl + Enter. The TypeScript streams into the right-hand editor, and you can stop it early. One conversion takes up to 60,000 characters, so send one module at a time.
Compare it with the PythonCheck that each boto3 call has a matching command, that every try block wraps the same calls as the original try/except, and that any TODO: comments are resolved. Then Copy it or Download it as converted.ts.
Install and type-checkRun npm install for each @aws-sdk/* package the file imports, then npx tsc --noEmit and your tests. The compiler catches misspelled parameter names that Python would only reject at runtime.
Your Python is checked for secrets in the browser before it's sent for conversion.
Why move boto3 code to TypeScript and SDK v3
Teams usually port boto3 code when the logic has to live somewhere Python doesn't: a Node.js API, a TypeScript Lambda function that shares types with a frontend, or a CDK app written in TypeScript. Rewriting it by hand is slow because every call changes shape. Snake_case methods turn into command classes, blocking calls turn into promises, and response dictionaries turn into typed objects.
The converter does that mechanical part one module at a time and keeps your function structure and comments where they still apply, so the TypeScript reads like the Python you started with. The review work stays with you: error handling, pagination and data types, where the two SDKs genuinely differ.
SDK v3 is the version to target. It's the supported AWS SDK for JavaScript, it's included in the Lambda Node.js 18 and later runtimes, and you install only the service clients you use. If the destination project is still pinned to the old aws-sdk package, use the boto3 to SDK v2 converter instead.
The biggest shift: blocking boto3 calls become awaited v3 commands.
How boto3 maps to AWS SDK for JavaScript v3
Each boto3 client call becomes a v3 command sent through a client. s3.put_object(Bucket=b, Key=k, Body=data) becomes await s3.send(new PutObjectCommand({ Bucket: b, Key: k, Body: data })). The parameter names are identical because both SDKs follow the AWS API, but every call becomes asynchronous, so the converted functions are async and use await.
boto3's resource interface needs the most translation. A DynamoDB Table resource maps best to DynamoDBDocumentClient from @aws-sdk/lib-dynamodb, which accepts plain JavaScript values. boto3 paginators become v3 helpers such as paginateScan or paginateListObjectsV2, used with for await.
Error handling changes from except ClientError and reading err.response["Error"]["Code"] to try/catch with err.name or service exception classes such as NoSuchKey. The AWS SDK for JavaScript v3 developer guide covers each of these patterns.
Six boto3 patterns and the SDK v3 code they turn into.
boto3 vs AWS SDK v3: quick reference
The patterns the converter rewrites most often. Parameter names don't change, because both SDKs are generated from the same AWS API definitions.
boto3 compared with AWS SDK for JavaScript v3, by task
Task
boto3 (Python)
SDK v3 (TypeScript)
Install
pip install boto3
npm install @aws-sdk/client-s3 (one package per service)
Create a client
boto3.client("s3")
new S3Client({})
Set the region
boto3.client("s3", region_name="eu-west-1")
new S3Client({ region: "eu-west-1" })
Named profile
boto3.Session(profile_name="dev")
fromIni({ profile: "dev" }) from @aws-sdk/credential-providers
Call an API
s3.put_object(Bucket=b, Key=k)
await s3.send(new PutObjectCommand({ Bucket: b, Key: k }))
DynamoDB items
boto3.resource("dynamodb").Table("orders")
DynamoDBDocumentClient.from(new DynamoDBClient({})) from @aws-sdk/lib-dynamodb
Read an S3 object
obj["Body"].read()
await obj.Body.transformToString()
Pagination
s3.get_paginator("list_objects_v2")
for await (const page of paginateListObjectsV2({ client }, params))
Waiters
s3.get_waiter("bucket_exists").wait(Bucket=b)
await waitUntilBucketExists({ client, maxWaitTime: 60 }, { Bucket: b })
Clients and resourcesBoth boto3.client() and boto3.resource() code converts. Resource calls become the matching commands, and DynamoDB Table objects become DynamoDBDocumentClient.
Async by defaultFunctions that call AWS become async, every SDK call is awaited, and a script's if __name__ == "__main__" block becomes a top-level call.
Typed outputParameters and return values get TypeScript types, so the compiler checks your v3 input objects against the SDK's own type definitions.
Your logic stays putFunction structure and business logic stay as they were, names follow TypeScript's camelCase convention, and comments carry over where they still apply.
Gaps marked with TODOWhen a boto3 feature has no direct v3 equivalent, the converter writes the closest version and adds a TODO: comment saying what to check.
Secret check firstAWS keys, private keys and common API tokens are detected in your browser before the code is sent.
Stream, copy, downloadWatch the TypeScript arrive, stop early if you need to, then copy it or download converted.ts.
Free to useNo signup needed. A free account raises the limit to 200 conversions a day and lists recent ones on your dashboard.
Examples: boto3 code converted to TypeScript
Three everyday boto3 patterns and the SDK v3 TypeScript they should become. Choose Try this example to load the Python into the converter. Your output may differ in naming and formatting.
Add up object sizes with a paginator
boto3's get_paginator becomes a v3 paginator function consumed with for await. Output fields are optional in the v3 types, hence the ?? [] and ?? 0.
boto3
import boto3
s3 = boto3.client("s3")
def total_size(bucket: str, prefix: str = "") -> int:
"""Add up the size of every object under a prefix."""
size = 0
paginator = s3.get_paginator("list_objects_v2")
for page in paginator.paginate(Bucket=bucket, Prefix=prefix):
for obj in page.get("Contents", []):
size += obj["Size"]
return size
SDK v3
import { S3Client, paginateListObjectsV2 } from "@aws-sdk/client-s3";
const s3 = new S3Client({});
/** Add up the size of every object under a prefix. */
export async function totalSize(bucket: string, prefix = ""): Promise<number> {
let size = 0;
const pages = paginateListObjectsV2({ client: s3 }, { Bucket: bucket, Prefix: prefix });
for await (const page of pages) {
for (const obj of page.Contents ?? []) {
size += obj.Size ?? 0;
}
}
return size;
}
Update a DynamoDB item with a condition
The Table resource becomes DynamoDBDocumentClient, so values stay plain. The error-code comparison becomes an instanceof check against the exported exception class, and raise becomes throw err.
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
import { getSignedUrl } from "@aws-sdk/s3-request-presigner";
const s3 = new S3Client({});
export function downloadLink(bucket: string, key: string): Promise<string> {
return getSignedUrl(s3, new GetObjectCommand({ Bucket: bucket, Key: key }), {
expiresIn: 3600,
});
}
Tips for better results
Send whole functions with their imports. The import boto3 lines and client setup tell the converter which services, and which interface (client or resource), you use.
Delete hard-coded credentials first. SDK v3 reads the same environment variables, ~/.aws profiles and IAM roles as boto3, so the converted code rarely needs keys in it.
Create clients once. Keep them at module level, especially in Lambda, where they're reused across invocations instead of rebuilt per request.
Type-check before you run.npx tsc --noEmit flags wrong parameter names and misused responses faster than a test run.
Port your tests too. Tests built on moto or botocore.stub.Stubber need a JavaScript replacement such as aws-sdk-client-mock.
Common mistakes when porting boto3 to TypeScript
Forgetting await. boto3 calls return data; v3 calls return promises. A missing await leaves you holding a pending promise, and its errors escape your try block.
Changing what a try block covers. Compare each try/catch with the original try/except. A single try that now also wraps an S3 write turns a loud failure into a quiet return false.
Reading an S3 Body like a Python stream. There's no .read() in v3. Use await Body.transformToString() or transformToByteArray().
Trusting DynamoDB number types. boto3's resource returns Decimal; the DocumentClient returns JavaScript numbers, which lose precision above 253. Set unmarshallOptions: { wrapNumbers: true } for very large values.
Looking for err.response. v3 errors expose err.name and err.$metadata.httpStatusCode; there's no response dictionary.
Installing only @aws-sdk/client-dynamodb. Code that uses DynamoDBDocumentClient also needs @aws-sdk/lib-dynamodb.
Frequently asked questions
How do I convert boto3 code to TypeScript?
Paste the Python into the converter at the top of this page and press Convert to TypeScript (or Ctrl + Enter). Each boto3 client becomes an SDK v3 client and each call becomes await client.send(new SomethingCommand(params)). Install the @aws-sdk/* packages the result imports, then run tsc and your tests.
Does it convert boto3 resources as well as clients?
Yes. Resource calls such as Table.get_item or Bucket.objects.all() are rewritten as the equivalent v3 commands or paginators. Review these closely, because v3 has no one-to-one resource API.
Why is the output TypeScript and not JavaScript?
The v3 SDK ships complete TypeScript types, so typed output catches mistakes in parameter names early. If you need plain JavaScript, compile it with tsc or remove the type annotations. The SDK calls stay the same.
Do boto3 and SDK v3 use the same parameter names?
Yes. Both SDKs are generated from the same AWS API definitions, so Bucket, Key and TableName keep their names and casing. What changes is how you call them: put_object becomes PutObjectCommand sent through a client.
Can I run the converted code in AWS Lambda?
Yes. The Lambda Node.js 18 and later runtimes include SDK v3, so the clients are available without bundling, though pinning your own version is good practice. Export a handler and give the function's role the permissions the code needs. The IAM policy generator for TypeScript can draft that policy from the converted file.
What about boto3 waiters and presigned URLs?
Both have v3 equivalents. Waiters become functions such as waitUntilBucketExists, and presigned URLs come from getSignedUrl in @aws-sdk/s3-request-presigner. The quick reference above shows the mapping; check that the converted code imports them from the right packages. The guide to port a Python boto3 script to Node.js with SDK v3 covers paginators, waiters and errors in depth.
Is my code stored?
No. The Python you convert goes to an AI model hosted on NVIDIA's API only to produce the TypeScript, and ChatWithCloud doesn't keep or log it. Your last draft stays in this browser's local storage. For the full picture, see whether it's safe to paste AWS code into an AI converter.
Is it free, and how much can I convert at once?
Yes, it's free. A single conversion accepts up to 60,000 characters, and files up to 500 KB. You can run 6 conversions a minute and 60 a day without an account, or 12 a minute and 200 a day with a free account. The guide to ChatWithCloud free converter limits shows how far they stretch for a real migration.