How to convert boto3 code to AWS SDK v3
- Add your codePaste it into the Python (boto3) editor, drag in a file, or keep the sample to see how it works.
- Convert to TypeScriptClick the button or press Ctrl + Enter. The result streams into the right-hand editor.
- Review and use itCopy or download the result, then test it before you rely on it. AI output is a strong first draft, not a guarantee.
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.
Tips for better results
- Install one package per client. For example
npm install @aws-sdk/client-s3 @aws-sdk/client-dynamodb @aws-sdk/lib-dynamodbfor the sample. - Remove hard-coded keys first. If your script passes
aws_access_key_id, delete it before converting. The JavaScript SDK uses the same default credential chain as boto3. - Check S3 downloads.
get_object()["Body"].read()becomesawait Body.transformToString()ortransformToByteArray(). - Watch number types. boto3's DynamoDB resource returns
Decimal, while the DocumentClient returns JavaScript numbers. Very large numbers may need thewrapNumbersoption. - Keep
__main__logic separate. Script entry points convert into a top-level call. For Lambda, export a handler function instead.
Frequently asked questions
Why TypeScript instead of JavaScript?
The v3 SDK ships complete TypeScript types, so typed output catches mistakes in parameter names early. If you need plain JavaScript, remove the type annotations. The SDK calls stay the same.
Does it handle 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.
Can I use the output in AWS Lambda?
Yes. The Node.js 18 and later Lambda runtimes include SDK v3. Export a handler function and grant the function's role the permissions the code needs.