How to convert AWS SDK v2 code to v3
- Add your codePaste it into the AWS SDK v2 (JS/TS) editor, drag in a file, or keep the sample to see how it works.
- Convert to v3Click 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.
What changes between SDK v2 and v3
Version 3 of the AWS SDK for JavaScript splits the single aws-sdk package into one package per service, such as @aws-sdk/client-s3. Instead of calling s3.getObject(params).promise(), you create a client and send a command: client.send(new GetObjectCommand(params)). The converter makes these changes for you: imports, client construction, command classes and the removal of .promise().
A few differences need more than a find-and-replace. DynamoDB's DocumentClient becomes DynamoDBDocumentClient from @aws-sdk/lib-dynamodb. S3 object bodies arrive as streams instead of Buffers, so you read them with Body.transformToString() or transformToByteArray(). Pagination moves to built-in helpers such as paginateListObjectsV2. Check each of these in the converted code.
For a large codebase, AWS also publishes aws-sdk-js-codemod, a jscodeshift transform for bulk changes, and an official migration guide. This converter is useful for the files the codemod can't handle cleanly, and for understanding what the v3 version of a snippet should look like.
The v3 SDK is modular, so install each client the converted code imports, for example npm install @aws-sdk/client-s3 @aws-sdk/lib-dynamodb @aws-sdk/client-dynamodb.
Tips for better results
- Convert one module at a time. A single file with its imports converts more reliably than a whole project pasted at once.
- Keep the import lines. They tell the converter which services and client styles you use, such as
DocumentClientversus the low-level DynamoDB client. - Check stream handling. Any code that treats an S3
Bodyas a Buffer needs to read the stream in v3. - Check error handling. v3 errors are service exception classes, and the HTTP status is in
error.$metadata.httpStatusCodeinstead oferror.statusCode. - Run your tests. Mock libraries change too:
aws-sdk-client-mockreplaces most v2 mocking approaches.
Frequently asked questions
Is AWS SDK for JavaScript v2 still supported?
No. AWS SDK for JavaScript v2 entered maintenance mode on September 8, 2024 and reached end-of-support on September 8, 2025. It no longer receives updates, including security fixes, so AWS recommends moving to v3.
What are the main differences between v2 and v3?
v3 is modular, with one package per service, so your bundles only include the clients you use. It uses a command pattern (client.send(new Command())) with native promises, has first-class TypeScript types, and adds middleware for customizing requests.
Can I migrate to v3 gradually?
Yes. v2 and v3 can run side by side in the same project, so you can convert one service client or one file at a time and ship each change separately.
Does the converter change my application logic?
It aims to keep your logic the same and change only the SDK calls, imports and client setup. Review the output anyway, especially around S3 body streams, pagination and error handling, where v3 behaves differently.