Rewrite modular @aws-sdk/client-* v3 code as aws-sdk v2 calls when a legacy codebase can't move yet. AWS SDK for JavaScript v2 reached end-of-support on September 8, 2025, so treat v2 code as a stopgap.
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 AWS SDK v3 code to v2
To convert AWS SDK v3 code to v2, paste it into the editor above and press Convert to v2. Each client.send(new SomeCommand(params)) becomes the matching v2 method with .promise(), and the @aws-sdk/* imports become aws-sdk imports. Then make sure aws-sdk is installed or bundled, and test.
Add the v3 codePaste it into the AWS SDK v3 (JS/TS) editor, use Paste or Open file (.js, .mjs, .cjs, .jsx, .ts, .tsx or .txt, up to 500 KB), or drop a file on the editor. Sample loads an SQS and DynamoDB order processor.
Let the secret check runBefore the code leaves your browser, the page scans it for AWS access keys, secret keys, private keys and common API tokens. If it finds one, it highlights the match so you can replace it with a placeholder.
Convert to v2Click Convert to v2 or press Ctrl + Enter. The v2 code streams into the right-hand editor, and Stop cancels it. Up to 60,000 characters fit in one conversion.
Check the tricky partsCompare the result with your original, paying attention to paginator loops, error checks and S3 bodies. TODO: comments mark places with no direct v2 equivalent. Copy the code or download it as converted-v2.js.
Install or bundle aws-sdk and testAdd aws-sdk to package.json if it isn't there. On Lambda's Node.js 18 and later runtimes, bundle it with your function, because those runtimes don't include v2.
Nothing is sent until the browser-side secret check passes or you choose to continue.
When converting AWS SDK v3 code to v2 still makes sense
Most migrations go the other way, and for new code you should use v3. But some projects can't switch yet: an older service built around shared v2 helpers, a plugin or framework that expects a v2 client object, or a service stuck on an older Node.js version that current v3 releases no longer support. When you find a v3 example in the AWS docs or another repository and need it to fit that code today, rewriting it by hand is slow and easy to get subtly wrong.
This converter does that rewrite for one file or snippet at a time, keeping your function names, structure and comments so the change is easy to review. It's most useful for hotfixes and small additions to a legacy service, where adding a second SDK would complicate the release.
Because v2 no longer gets security fixes, keep a note of every file you convert. When the project is ready, the AWS SDK v2 to v3 converter takes the same code forward again.
v2 no longer gets updates or security fixes, so converted code should be temporary.
How AWS SDK v3 code maps back to v2
In v3, you create a client per service and send it command objects. In v2, one service object exposes a method per API operation, and you call .promise() to get a promise. So await s3.send(new GetObjectCommand(params)) becomes await s3.getObject(params).promise(), with the same parameter names. Separate @aws-sdk/client-* imports become require("aws-sdk") or a per-service import such as aws-sdk/clients/s3.
Helpers that only exist in v3 need more than renaming. Paginators such as paginateListObjectsV2 become loops that pass NextContinuationToken (or NextToken) into the next request. Custom middleware becomes request event listeners. DynamoDBDocumentClient commands like GetCommand become DocumentClient methods like get(). Errors are identified by err.code instead of err.name or exception classes.
Request event listeners such as req.on("build", …)
On Lambda
Included in Node.js 18+ runtimes
Not included in Node.js 18+ runtimes; bundle aws-sdk
Key features
Commands become v2 methodsEach client.send(new XCommand(params)) becomes the matching v2 service method with .promise(), keeping the same parameters.
Paginators rewritten as token loopsv3 paginate* helpers become explicit loops over the continuation token, since most v2 clients have no equivalent.
DocumentClient mapping@aws-sdk/lib-dynamodb commands such as PutCommand and QueryCommand become DocumentClient methods like put() and query().
Error checks translatederr.name comparisons and exception classes become err.code checks, which is how v2 reports error types.
Gaps flagged in the codeWhere v3 behavior has no v2 equivalent, the output carries a TODO: comment explaining what to check.
Checked for secrets firstAccess keys, secret keys, private keys and common tokens are detected in your browser before any code is sent.
Free, no signupConvert straight away, then copy or download the result. A free account raises your limits.
Examples: AWS SDK v3 code converted to v2
Three patterns you're likely to meet when backporting. Choose Try this example to load the v3 version into the converter. Your output may be formatted differently.
Read an item with the DynamoDB DocumentClient
DynamoDBDocumentClient.from() and GetCommand become a v2 DocumentClient and its get() method. The item comes back as a plain object in both versions.
v2 has no paginateListObjectsV2, so the loop passes NextContinuationToken back as ContinuationToken until S3 stops returning one.
SDK v3
import { S3Client, paginateListObjectsV2 } from "@aws-sdk/client-s3";
const client = new S3Client({});
export async function listKeys(bucket, prefix) {
const keys = [];
for await (const page of paginateListObjectsV2({ client }, { Bucket: bucket, Prefix: prefix })) {
for (const obj of page.Contents ?? []) keys.push(obj.Key);
}
return keys;
}
SDK v2
import S3 from "aws-sdk/clients/s3";
const s3 = new S3();
export async function listKeys(bucket, prefix) {
const keys = [];
let token;
do {
const page = await s3
.listObjectsV2({ Bucket: bucket, Prefix: prefix, ContinuationToken: token })
.promise();
for (const obj of page.Contents ?? []) keys.push(obj.Key);
token = page.NextContinuationToken;
} while (token);
return keys;
}
Load a JSON file from S3 and handle a missing key
Two things change: the body is a Buffer in v2, so transformToString() becomes toString("utf-8"), and the error check moves from err.name to err.code.
SDK v3
import { S3Client, GetObjectCommand } from "@aws-sdk/client-s3";
const s3 = new S3Client({ region: "us-east-1" });
export async function loadConfig(key) {
try {
const res = await s3.send(new GetObjectCommand({ Bucket: "app-config", Key: key }));
return JSON.parse(await res.Body.transformToString());
} catch (err) {
if (err.name === "NoSuchKey") return {};
throw err;
}
}
SDK v2
import S3 from "aws-sdk/clients/s3";
const s3 = new S3({ region: "us-east-1" });
export async function loadConfig(key) {
try {
const res = await s3.getObject({ Bucket: "app-config", Key: key }).promise();
return JSON.parse(res.Body.toString("utf-8"));
} catch (err) {
if (err.code === "NoSuchKey") return {};
throw err;
}
}
Tips for better results
Paste the imports with the code. They show which clients you use, and whether DynamoDB calls go through lib-dynamodb or the low-level client.
Match the module style of the target file. If the legacy project uses require(), say so in a comment at the top, or adjust the imports after converting.
Test pagination with more than one page. A token loop that works on a single page can still stop early or loop forever if the token handling is off.
Re-add TypeScript types if you need them. TypeScript input can come back as plain JavaScript. v2 ships its own typings, such as S3.GetObjectOutput, which replace v3's GetObjectCommandOutput.
Keep v2 and v3 separate. They can live in one project, but don't pass a v3 client into v2 helpers or the other way round.
Common mistakes when backporting to v2
Leaving transformToString() on an S3 body. v2 returns a Buffer, which has no such method, so the call throws at runtime.
Checking err.name or instanceof. v2 errors carry the type in err.code, such as NoSuchKey or ConditionalCheckFailedException.
Forgetting .promise(). Without it, await gets a v2 Request object instead of the response.
Mixing DocumentClient and low-level shapes. The DocumentClient takes plain values like { userId: "42" }. The low-level client expects typed attributes like { userId: { S: "42" } }.
Frequently asked questions
How do I convert AWS SDK v3 code to v2?
Paste the v3 code into the converter at the top of this page and press Convert to v2. It replaces each client.send(new Command(params)) call with the matching v2 method plus .promise() and rewrites the imports for aws-sdk. Then check paginators, error handling and S3 bodies, and test.
Should I use AWS SDK v2 for new projects?
No. v2 reached end-of-support on September 8, 2025 and gets no more updates, including security fixes. Use v3 for anything new, and only convert to v2 when existing code has to stay on it for now.
Can v2 and v3 code live in the same project?
Yes. The aws-sdk and @aws-sdk/* packages don't conflict, so a converted v2 file can sit next to v3 code while you migrate the rest.
What happens to v3 paginators in v2?
Most v2 clients have no paginate* helpers. The converter rewrites them as loops that pass the continuation token from each response into the next request. Test them against more than one page of results.
Does the converter work with TypeScript?
You can paste TypeScript, including .ts and .tsx files. The output may come back as plain JavaScript, so add types back where you need them using the typings that ship with v2, such as S3.GetObjectOutput.
Will my v2 code run on AWS Lambda?
Yes, if you include aws-sdk in the deployment package. Lambda's Node.js 18 and later runtimes include SDK v3 but not v2.
Is my code stored?
No. The code is sent to an AI model hosted on NVIDIA's API only to produce the conversion, and ChatWithCloud doesn't store or log it. Your latest draft stays in your browser. Swap real keys and passwords for placeholders before converting. For the full picture, see whether it's safe to paste AWS code into an AI converter.
Is the converter free?
Yes, it's free. Each conversion takes up to 60,000 characters, and files up to 500 KB. Without an account you can run 6 conversions a minute and 60 a day. A free account raises that to 12 a minute and 200 a day and lists your recent conversions on your dashboard. The guide to ChatWithCloud free converter limits shows how far they stretch for a real migration.