How to edit a file in S3 without downloading it first
S3 has no edit API, only GetObject and PutObject — every 'edit' is really a full read, a change, and a full conditional rewrite of the object. For small text files (JSON, YAML, Markdown, config, .env, logs, and similar, up to 1 MB in S3 Viewer) that loop is fast enough to feel instant. S3 Viewer's Edit button opens a text-like object directly in the browser and saves it back with the same reviewed-ETag condition every replacement uses, so a change made elsewhere in the meantime is caught instead of silently overwritten.
Step-by-step.
- 01
In S3 Viewer: click Edit on a text-like object
Open an object with a text-like content type or extension (.json,.yml,.md,.csv,.env,.log, and similar) under 1 MB and click Edit. The preview switches to a plain-text editor with line numbers; a dirty indicator marks unsaved changes, and Cmd/Ctrl+S saves without reaching for the mouse. Leaving with unsaved changes prompts for confirmation. - 02
Save conditions on the version you opened
Saving PUTs the new content back with the ETag you had open as a condition — the same conditional replacement path a manual re-upload uses. If the object changed after you opened it, the save is refused with a message to reload rather than overwriting someone else's write. - 03
AWS CLI: download, edit, upload
No shortcut here — copy the object down, edit it locally, and copy it back. Check the ETag before and after if you want the same protection S3 Viewer gives you automatically.aws s3 cp s3://my-bucket/config/settings.json ./settings.json $EDITOR ./settings.json aws s3 cp ./settings.json s3://my-bucket/config/settings.json - 04
AWS SDK: getObject, transform, conditional putObject
Read the body, make your change, and write it back withIfMatchset to the ETag you read — this is the scripted version of what S3 Viewer's Edit does under the hood.const { Body, ETag } = await s3.getObject({ Bucket: 'my-bucket', Key: 'config/settings.json' }); const text = await Body.transformToString(); const updated = JSON.stringify({ ...JSON.parse(text), debug: false }); await s3.putObject({ Bucket: 'my-bucket', Key: 'config/settings.json', Body: updated, IfMatch: ETag, }); - 05
Large or binary files: edit locally instead
An in-browser editor only makes sense for small text — S3 Viewer caps it at 1 MB, and a multi-megabyte log or a binary file wouldn't render usefully as a textarea anyway. Download, edit with the right tool, and re-upload for anything past that line.
What's actually happening.
S3's object API has exactly two operations that touch content: GetObject reads the whole body, and PutObject replaces it whole. There is nothing between them — no patch, no append, no byte-range write. Editing a file is therefore always: read everything, change what you want, write everything back.
S3 Viewer's Edit button runs that loop for you: it HEADs the object first (refusing anything over 1 MB before a byte transfers), streams the body into a plain-text editor with the object's ETag captured alongside it, and on save PUTs the new content back through the same route a manual replacement upload uses — expectedETag included, so a change made elsewhere between opening and saving is caught as a conflict rather than silently discarded.
The 1 MB ceiling isn't arbitrary caution: a textarea holding a multi-megabyte file is a poor editor regardless of how fast the network is, and the file is more likely binary or log-shaped at that size anyway. Nothing about the underlying read-and-write pattern actually changes past that point — only the UI stops being the right tool for it.
Common questions.
Can I edit a file directly in S3?
What file types can S3 Viewer edit in place?
Will I lose my changes if someone else edits the file first?
How do I edit a JSON or config file in an S3 bucket from the terminal?
Does editing a file in S3 create a new version?
Can I edit a file in Cloudflare R2 or Backblaze B2 the same way?
Skip the CLI. Try it in the browser.
S3 Viewer turns the steps above into a single click. Open source, self-hostable, free.
Why teams pick this
More how-tos
Edit object metadata
There's no UpdateObject call — changing a header means copying the object onto itself with MetadataDirective REPLACE.
Upload large files
How large uploads work in S3 Viewer and from the CLI — streaming, retries, and the 5 GB single-PUT cap.
Rename an S3 file
Amazon S3 has no rename API — keys are immutable. Here's the standard copy + delete pattern, with metadata and tags preserved.